1 /*
2 * Copyright (c) 2008-2011 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
19 #include <linux/nl80211.h>
20 #include <linux/pci.h>
21 #include <linux/pci-aspm.h>
22 #include <linux/ath9k_platform.h>
23 #include <linux/module.h>
24 #include "ath9k.h"
25
26 static const struct pci_device_id ath_pci_id_table[] = {
27 { PCI_VDEVICE(ATHEROS, 0x0023) }, /* PCI */
28 { PCI_VDEVICE(ATHEROS, 0x0024) }, /* PCI-E */
29 { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */
30
31 #ifdef CONFIG_ATH9K_PCOEM
32 /* Mini PCI AR9220 MB92 cards: Compex WLM200NX, Wistron DNMA-92 */
33 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
34 0x0029,
35 PCI_VENDOR_ID_ATHEROS,
36 0x2096),
37 .driver_data = ATH9K_PCI_LED_ACT_HI },
38 #endif
39
40 { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI */
41
42 #ifdef CONFIG_ATH9K_PCOEM
43 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
44 0x002A,
45 PCI_VENDOR_ID_AZWAVE,
46 0x1C71),
47 .driver_data = ATH9K_PCI_D3_L1_WAR },
48 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
49 0x002A,
50 PCI_VENDOR_ID_FOXCONN,
51 0xE01F),
52 .driver_data = ATH9K_PCI_D3_L1_WAR },
53 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
54 0x002A,
55 0x11AD, /* LITEON */
56 0x6632),
57 .driver_data = ATH9K_PCI_D3_L1_WAR },
58 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
59 0x002A,
60 0x11AD, /* LITEON */
61 0x6642),
62 .driver_data = ATH9K_PCI_D3_L1_WAR },
63 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
64 0x002A,
65 PCI_VENDOR_ID_QMI,
66 0x0306),
67 .driver_data = ATH9K_PCI_D3_L1_WAR },
68 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
69 0x002A,
70 0x185F, /* WNC */
71 0x309D),
72 .driver_data = ATH9K_PCI_D3_L1_WAR },
73 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
74 0x002A,
75 0x10CF, /* Fujitsu */
76 0x147C),
77 .driver_data = ATH9K_PCI_D3_L1_WAR },
78 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
79 0x002A,
80 0x10CF, /* Fujitsu */
81 0x147D),
82 .driver_data = ATH9K_PCI_D3_L1_WAR },
83 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
84 0x002A,
85 0x10CF, /* Fujitsu */
86 0x1536),
87 .driver_data = ATH9K_PCI_D3_L1_WAR },
88 #endif
89
90 { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */
91
92 #ifdef CONFIG_ATH9K_PCOEM
93 /* AR9285 card for Asus */
94 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
95 0x002B,
96 PCI_VENDOR_ID_AZWAVE,
97 0x2C37),
98 .driver_data = ATH9K_PCI_BT_ANT_DIV },
99 #endif
100
101 { PCI_VDEVICE(ATHEROS, 0x002B) }, /* PCI-E */
102 { PCI_VDEVICE(ATHEROS, 0x002C) }, /* PCI-E 802.11n bonded out */
103 { PCI_VDEVICE(ATHEROS, 0x002D) }, /* PCI */
104 { PCI_VDEVICE(ATHEROS, 0x002E) }, /* PCI-E */
105
106 /* Killer Wireless (3x3) */
107 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
108 0x0030,
109 0x1A56,
110 0x2000),
111 .driver_data = ATH9K_PCI_KILLER },
112 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
113 0x0030,
114 0x1A56,
115 0x2001),
116 .driver_data = ATH9K_PCI_KILLER },
117
118 { PCI_VDEVICE(ATHEROS, 0x0030) }, /* PCI-E AR9300 */
119
120 #ifdef CONFIG_ATH9K_PCOEM
121 /* PCI-E CUS198 */
122 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
123 0x0032,
124 PCI_VENDOR_ID_AZWAVE,
125 0x2086),
126 .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
127 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
128 0x0032,
129 PCI_VENDOR_ID_AZWAVE,
130 0x1237),
131 .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
132 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
133 0x0032,
134 PCI_VENDOR_ID_AZWAVE,
135 0x2126),
136 .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
137 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
138 0x0032,
139 PCI_VENDOR_ID_AZWAVE,
140 0x126A),
141 .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
142
143 /* PCI-E CUS230 */
144 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
145 0x0032,
146 PCI_VENDOR_ID_AZWAVE,
147 0x2152),
148 .driver_data = ATH9K_PCI_CUS230 | ATH9K_PCI_BT_ANT_DIV },
149 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
150 0x0032,
151 PCI_VENDOR_ID_FOXCONN,
152 0xE075),
153 .driver_data = ATH9K_PCI_CUS230 | ATH9K_PCI_BT_ANT_DIV },
154
155 /* WB225 */
156 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
157 0x0032,
158 PCI_VENDOR_ID_ATHEROS,
159 0x3119),
160 .driver_data = ATH9K_PCI_BT_ANT_DIV },
161 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
162 0x0032,
163 PCI_VENDOR_ID_ATHEROS,
164 0x3122),
165 .driver_data = ATH9K_PCI_BT_ANT_DIV },
166 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
167 0x0032,
168 0x185F, /* WNC */
169 0x3119),
170 .driver_data = ATH9K_PCI_BT_ANT_DIV },
171 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
172 0x0032,
173 0x185F, /* WNC */
174 0x3027),
175 .driver_data = ATH9K_PCI_BT_ANT_DIV },
176 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
177 0x0032,
178 PCI_VENDOR_ID_SAMSUNG,
179 0x4105),
180 .driver_data = ATH9K_PCI_BT_ANT_DIV },
181 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
182 0x0032,
183 PCI_VENDOR_ID_SAMSUNG,
184 0x4106),
185 .driver_data = ATH9K_PCI_BT_ANT_DIV },
186 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
187 0x0032,
188 PCI_VENDOR_ID_SAMSUNG,
189 0x410D),
190 .driver_data = ATH9K_PCI_BT_ANT_DIV },
191 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
192 0x0032,
193 PCI_VENDOR_ID_SAMSUNG,
194 0x410E),
195 .driver_data = ATH9K_PCI_BT_ANT_DIV },
196 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
197 0x0032,
198 PCI_VENDOR_ID_SAMSUNG,
199 0x410F),
200 .driver_data = ATH9K_PCI_BT_ANT_DIV },
201 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
202 0x0032,
203 PCI_VENDOR_ID_SAMSUNG,
204 0xC706),
205 .driver_data = ATH9K_PCI_BT_ANT_DIV },
206 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
207 0x0032,
208 PCI_VENDOR_ID_SAMSUNG,
209 0xC680),
210 .driver_data = ATH9K_PCI_BT_ANT_DIV },
211 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
212 0x0032,
213 PCI_VENDOR_ID_SAMSUNG,
214 0xC708),
215 .driver_data = ATH9K_PCI_BT_ANT_DIV },
216 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
217 0x0032,
218 PCI_VENDOR_ID_LENOVO,
219 0x3218),
220 .driver_data = ATH9K_PCI_BT_ANT_DIV },
221 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
222 0x0032,
223 PCI_VENDOR_ID_LENOVO,
224 0x3219),
225 .driver_data = ATH9K_PCI_BT_ANT_DIV },
226
227 /* AR9485 cards with PLL power-save disabled by default. */
228 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
229 0x0032,
230 PCI_VENDOR_ID_AZWAVE,
231 0x2C97),
232 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
233 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
234 0x0032,
235 PCI_VENDOR_ID_AZWAVE,
236 0x2100),
237 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
238 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
239 0x0032,
240 0x1C56, /* ASKEY */
241 0x4001),
242 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
243 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
244 0x0032,
245 0x11AD, /* LITEON */
246 0x6627),
247 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
248 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
249 0x0032,
250 0x11AD, /* LITEON */
251 0x6628),
252 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
253 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
254 0x0032,
255 PCI_VENDOR_ID_FOXCONN,
256 0xE04E),
257 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
258 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
259 0x0032,
260 PCI_VENDOR_ID_FOXCONN,
261 0xE04F),
262 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
263 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
264 0x0032,
265 0x144F, /* ASKEY */
266 0x7197),
267 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
268 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
269 0x0032,
270 0x1B9A, /* XAVI */
271 0x2000),
272 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
273 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
274 0x0032,
275 0x1B9A, /* XAVI */
276 0x2001),
277 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
278 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
279 0x0032,
280 PCI_VENDOR_ID_AZWAVE,
281 0x1186),
282 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
283 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
284 0x0032,
285 PCI_VENDOR_ID_AZWAVE,
286 0x1F86),
287 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
288 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
289 0x0032,
290 PCI_VENDOR_ID_AZWAVE,
291 0x1195),
292 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
293 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
294 0x0032,
295 PCI_VENDOR_ID_AZWAVE,
296 0x1F95),
297 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
298 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
299 0x0032,
300 0x1B9A, /* XAVI */
301 0x1C00),
302 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
303 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
304 0x0032,
305 0x1B9A, /* XAVI */
306 0x1C01),
307 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
308 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
309 0x0032,
310 PCI_VENDOR_ID_ASUSTEK,
311 0x850D),
312 .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
313 #endif
314
315 { PCI_VDEVICE(ATHEROS, 0x0032) }, /* PCI-E AR9485 */
316 { PCI_VDEVICE(ATHEROS, 0x0033) }, /* PCI-E AR9580 */
317
318 #ifdef CONFIG_ATH9K_PCOEM
319 /* PCI-E CUS217 */
320 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
321 0x0034,
322 PCI_VENDOR_ID_AZWAVE,
323 0x2116),
324 .driver_data = ATH9K_PCI_CUS217 },
325 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
326 0x0034,
327 0x11AD, /* LITEON */
328 0x6661),
329 .driver_data = ATH9K_PCI_CUS217 },
330
331 /* AR9462 with WoW support */
332 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
333 0x0034,
334 PCI_VENDOR_ID_ATHEROS,
335 0x3117),
336 .driver_data = ATH9K_PCI_WOW },
337 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
338 0x0034,
339 PCI_VENDOR_ID_LENOVO,
340 0x3214),
341 .driver_data = ATH9K_PCI_WOW },
342 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
343 0x0034,
344 PCI_VENDOR_ID_ATTANSIC,
345 0x0091),
346 .driver_data = ATH9K_PCI_WOW },
347 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
348 0x0034,
349 PCI_VENDOR_ID_AZWAVE,
350 0x2110),
351 .driver_data = ATH9K_PCI_WOW },
352 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
353 0x0034,
354 PCI_VENDOR_ID_ASUSTEK,
355 0x850E),
356 .driver_data = ATH9K_PCI_WOW },
357 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
358 0x0034,
359 0x11AD, /* LITEON */
360 0x6631),
361 .driver_data = ATH9K_PCI_WOW },
362 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
363 0x0034,
364 0x11AD, /* LITEON */
365 0x6641),
366 .driver_data = ATH9K_PCI_WOW },
367 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
368 0x0034,
369 PCI_VENDOR_ID_HP,
370 0x1864),
371 .driver_data = ATH9K_PCI_WOW },
372 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
373 0x0034,
374 0x14CD, /* USI */
375 0x0063),
376 .driver_data = ATH9K_PCI_WOW },
377 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
378 0x0034,
379 0x14CD, /* USI */
380 0x0064),
381 .driver_data = ATH9K_PCI_WOW },
382 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
383 0x0034,
384 0x10CF, /* Fujitsu */
385 0x1783),
386 .driver_data = ATH9K_PCI_WOW },
387
388 /* Killer Wireless (2x2) */
389 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
390 0x0030,
391 0x1A56,
392 0x2003),
393 .driver_data = ATH9K_PCI_KILLER },
394
395 { PCI_VDEVICE(ATHEROS, 0x0034) }, /* PCI-E AR9462 */
396 { PCI_VDEVICE(ATHEROS, 0x0037) }, /* PCI-E AR1111/AR9485 */
397
398 /* CUS252 */
399 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
400 0x0036,
401 PCI_VENDOR_ID_ATHEROS,
402 0x3028),
403 .driver_data = ATH9K_PCI_CUS252 |
404 ATH9K_PCI_AR9565_2ANT |
405 ATH9K_PCI_BT_ANT_DIV },
406 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
407 0x0036,
408 PCI_VENDOR_ID_AZWAVE,
409 0x2176),
410 .driver_data = ATH9K_PCI_CUS252 |
411 ATH9K_PCI_AR9565_2ANT |
412 ATH9K_PCI_BT_ANT_DIV },
413
414 /* WB335 1-ANT */
415 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
416 0x0036,
417 PCI_VENDOR_ID_FOXCONN,
418 0xE068),
419 .driver_data = ATH9K_PCI_AR9565_1ANT },
420 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
421 0x0036,
422 0x185F, /* WNC */
423 0xA119),
424 .driver_data = ATH9K_PCI_AR9565_1ANT },
425 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
426 0x0036,
427 0x11AD, /* LITEON */
428 0x0632),
429 .driver_data = ATH9K_PCI_AR9565_1ANT },
430 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
431 0x0036,
432 0x11AD, /* LITEON */
433 0x06B2),
434 .driver_data = ATH9K_PCI_AR9565_1ANT },
435 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
436 0x0036,
437 0x11AD, /* LITEON */
438 0x0842),
439 .driver_data = ATH9K_PCI_AR9565_1ANT },
440 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
441 0x0036,
442 0x11AD, /* LITEON */
443 0x1842),
444 .driver_data = ATH9K_PCI_AR9565_1ANT },
445 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
446 0x0036,
447 0x11AD, /* LITEON */
448 0x6671),
449 .driver_data = ATH9K_PCI_AR9565_1ANT },
450 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
451 0x0036,
452 0x1B9A, /* XAVI */
453 0x2811),
454 .driver_data = ATH9K_PCI_AR9565_1ANT },
455 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
456 0x0036,
457 0x1B9A, /* XAVI */
458 0x2812),
459 .driver_data = ATH9K_PCI_AR9565_1ANT },
460 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
461 0x0036,
462 0x1B9A, /* XAVI */
463 0x28A1),
464 .driver_data = ATH9K_PCI_AR9565_1ANT },
465 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
466 0x0036,
467 0x1B9A, /* XAVI */
468 0x28A3),
469 .driver_data = ATH9K_PCI_AR9565_1ANT },
470 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
471 0x0036,
472 PCI_VENDOR_ID_AZWAVE,
473 0x218A),
474 .driver_data = ATH9K_PCI_AR9565_1ANT },
475 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
476 0x0036,
477 PCI_VENDOR_ID_AZWAVE,
478 0x2F8A),
479 .driver_data = ATH9K_PCI_AR9565_1ANT },
480
481 /* WB335 1-ANT / Antenna Diversity */
482 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
483 0x0036,
484 PCI_VENDOR_ID_ATHEROS,
485 0x3025),
486 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
487 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
488 0x0036,
489 PCI_VENDOR_ID_ATHEROS,
490 0x3026),
491 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
492 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
493 0x0036,
494 PCI_VENDOR_ID_ATHEROS,
495 0x302B),
496 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
497 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
498 0x0036,
499 PCI_VENDOR_ID_FOXCONN,
500 0xE069),
501 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
502 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
503 0x0036,
504 0x185F, /* WNC */
505 0x3028),
506 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
507 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
508 0x0036,
509 0x11AD, /* LITEON */
510 0x0622),
511 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
512 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
513 0x0036,
514 0x11AD, /* LITEON */
515 0x0672),
516 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
517 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
518 0x0036,
519 0x11AD, /* LITEON */
520 0x0662),
521 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
522 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
523 0x0036,
524 0x11AD, /* LITEON */
525 0x06A2),
526 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
527 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
528 0x0036,
529 0x11AD, /* LITEON */
530 0x0682),
531 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
532 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
533 0x0036,
534 PCI_VENDOR_ID_AZWAVE,
535 0x213A),
536 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
537 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
538 0x0036,
539 PCI_VENDOR_ID_AZWAVE,
540 0x213C),
541 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
542 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
543 0x0036,
544 PCI_VENDOR_ID_HP,
545 0x18E3),
546 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
547 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
548 0x0036,
549 PCI_VENDOR_ID_HP,
550 0x217F),
551 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
552 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
553 0x0036,
554 PCI_VENDOR_ID_HP,
555 0x2005),
556 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
557 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
558 0x0036,
559 PCI_VENDOR_ID_DELL,
560 0x020C),
561 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
562
563 /* WB335 2-ANT / Antenna-Diversity */
564 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
565 0x0036,
566 PCI_VENDOR_ID_SAMSUNG,
567 0x411A),
568 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
569 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
570 0x0036,
571 PCI_VENDOR_ID_SAMSUNG,
572 0x411B),
573 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
574 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
575 0x0036,
576 PCI_VENDOR_ID_SAMSUNG,
577 0x411C),
578 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
579 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
580 0x0036,
581 PCI_VENDOR_ID_SAMSUNG,
582 0x411D),
583 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
584 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
585 0x0036,
586 PCI_VENDOR_ID_SAMSUNG,
587 0x411E),
588 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
589 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
590 0x0036,
591 PCI_VENDOR_ID_SAMSUNG,
592 0x4129),
593 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
594 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
595 0x0036,
596 PCI_VENDOR_ID_SAMSUNG,
597 0x412A),
598 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
599 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
600 0x0036,
601 PCI_VENDOR_ID_ATHEROS,
602 0x3027),
603 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
604 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
605 0x0036,
606 PCI_VENDOR_ID_ATHEROS,
607 0x302C),
608 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
609 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
610 0x0036,
611 0x11AD, /* LITEON */
612 0x0642),
613 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
614 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
615 0x0036,
616 0x11AD, /* LITEON */
617 0x0652),
618 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
619 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
620 0x0036,
621 0x11AD, /* LITEON */
622 0x0612),
623 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
624 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
625 0x0036,
626 0x11AD, /* LITEON */
627 0x0832),
628 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
629 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
630 0x0036,
631 0x11AD, /* LITEON */
632 0x1832),
633 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
634 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
635 0x0036,
636 0x11AD, /* LITEON */
637 0x0692),
638 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
639 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
640 0x0036,
641 0x11AD, /* LITEON */
642 0x0803),
643 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
644 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
645 0x0036,
646 0x11AD, /* LITEON */
647 0x0813),
648 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
649 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
650 0x0036,
651 PCI_VENDOR_ID_AZWAVE,
652 0x2130),
653 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
654 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
655 0x0036,
656 PCI_VENDOR_ID_AZWAVE,
657 0x213B),
658 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
659 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
660 0x0036,
661 PCI_VENDOR_ID_AZWAVE,
662 0x2182),
663 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
664 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
665 0x0036,
666 PCI_VENDOR_ID_AZWAVE,
667 0x218B),
668 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
669 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
670 0x0036,
671 PCI_VENDOR_ID_AZWAVE,
672 0x218C),
673 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
674 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
675 0x0036,
676 PCI_VENDOR_ID_AZWAVE,
677 0x2F82),
678 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
679 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
680 0x0036,
681 0x144F, /* ASKEY */
682 0x7202),
683 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
684 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
685 0x0036,
686 0x1B9A, /* XAVI */
687 0x2810),
688 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
689 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
690 0x0036,
691 0x1B9A, /* XAVI */
692 0x2813),
693 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
694 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
695 0x0036,
696 0x1B9A, /* XAVI */
697 0x28A2),
698 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
699 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
700 0x0036,
701 0x1B9A, /* XAVI */
702 0x28A4),
703 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
704 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
705 0x0036,
706 0x185F, /* WNC */
707 0x3027),
708 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
709 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
710 0x0036,
711 0x185F, /* WNC */
712 0xA120),
713 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
714 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
715 0x0036,
716 PCI_VENDOR_ID_FOXCONN,
717 0xE07F),
718 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
719 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
720 0x0036,
721 PCI_VENDOR_ID_FOXCONN,
722 0xE08F),
723 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
724 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
725 0x0036,
726 PCI_VENDOR_ID_FOXCONN,
727 0xE081),
728 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
729 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
730 0x0036,
731 PCI_VENDOR_ID_FOXCONN,
732 0xE091),
733 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
734 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
735 0x0036,
736 PCI_VENDOR_ID_FOXCONN,
737 0xE099),
738 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
739 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
740 0x0036,
741 PCI_VENDOR_ID_LENOVO,
742 0x3026),
743 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
744 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
745 0x0036,
746 PCI_VENDOR_ID_LENOVO,
747 0x4026),
748 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
749 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
750 0x0036,
751 PCI_VENDOR_ID_ASUSTEK,
752 0x85F2),
753 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
754 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
755 0x0036,
756 PCI_VENDOR_ID_DELL,
757 0x020E),
758 .driver_data = ATH9K_PCI_AR9565_2ANT |
759 ATH9K_PCI_BT_ANT_DIV |
760 ATH9K_PCI_LED_ACT_HI},
761
762 /* PCI-E AR9565 (WB335) */
763 { PCI_VDEVICE(ATHEROS, 0x0036),
764 .driver_data = ATH9K_PCI_BT_ANT_DIV },
765 #endif
766
767 { 0 }
768 };
769
770
771 /* return bus cachesize in 4B word units */
ath_pci_read_cachesize(struct ath_common * common,int * csz)772 static void ath_pci_read_cachesize(struct ath_common *common, int *csz)
773 {
774 struct ath_softc *sc = (struct ath_softc *) common->priv;
775 u8 u8tmp;
776
777 pci_read_config_byte(to_pci_dev(sc->dev), PCI_CACHE_LINE_SIZE, &u8tmp);
778 *csz = (int)u8tmp;
779
780 /*
781 * This check was put in to avoid "unpleasant" consequences if
782 * the bootrom has not fully initialized all PCI devices.
783 * Sometimes the cache line size register is not set
784 */
785
786 if (*csz == 0)
787 *csz = DEFAULT_CACHELINE >> 2; /* Use the default size */
788 }
789
ath_pci_eeprom_read(struct ath_common * common,u32 off,u16 * data)790 static bool ath_pci_eeprom_read(struct ath_common *common, u32 off, u16 *data)
791 {
792 struct ath_softc *sc = (struct ath_softc *) common->priv;
793 struct ath9k_platform_data *pdata = sc->dev->platform_data;
794
795 if (pdata && !pdata->use_eeprom) {
796 if (off >= (ARRAY_SIZE(pdata->eeprom_data))) {
797 ath_err(common,
798 "%s: eeprom read failed, offset %08x is out of range\n",
799 __func__, off);
800 }
801
802 *data = pdata->eeprom_data[off];
803 } else {
804 struct ath_hw *ah = (struct ath_hw *) common->ah;
805
806 common->ops->read(ah, AR5416_EEPROM_OFFSET +
807 (off << AR5416_EEPROM_S));
808
809 if (!ath9k_hw_wait(ah,
810 AR_EEPROM_STATUS_DATA,
811 AR_EEPROM_STATUS_DATA_BUSY |
812 AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0,
813 AH_WAIT_TIMEOUT)) {
814 return false;
815 }
816
817 *data = MS(common->ops->read(ah, AR_EEPROM_STATUS_DATA),
818 AR_EEPROM_STATUS_DATA_VAL);
819 }
820
821 return true;
822 }
823
824 /* Need to be called after we discover btcoex capabilities */
ath_pci_aspm_init(struct ath_common * common)825 static void ath_pci_aspm_init(struct ath_common *common)
826 {
827 struct ath_softc *sc = (struct ath_softc *) common->priv;
828 struct ath_hw *ah = sc->sc_ah;
829 struct pci_dev *pdev = to_pci_dev(sc->dev);
830 struct pci_dev *parent;
831 u16 aspm;
832
833 if (!ah->is_pciexpress)
834 return;
835
836 parent = pdev->bus->self;
837 if (!parent)
838 return;
839
840 if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) &&
841 (AR_SREV_9285(ah))) {
842 /* Bluetooth coexistence requires disabling ASPM. */
843 pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL,
844 PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1);
845
846 /*
847 * Both upstream and downstream PCIe components should
848 * have the same ASPM settings.
849 */
850 pcie_capability_clear_word(parent, PCI_EXP_LNKCTL,
851 PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1);
852
853 ath_info(common, "Disabling ASPM since BTCOEX is enabled\n");
854 return;
855 }
856
857 /*
858 * 0x70c - Ack Frequency Register.
859 *
860 * Bits 27:29 - DEFAULT_L1_ENTRANCE_LATENCY.
861 *
862 * 000 : 1 us
863 * 001 : 2 us
864 * 010 : 4 us
865 * 011 : 8 us
866 * 100 : 16 us
867 * 101 : 32 us
868 * 110/111 : 64 us
869 */
870 if (AR_SREV_9462(ah))
871 pci_read_config_dword(pdev, 0x70c, &ah->config.aspm_l1_fix);
872
873 pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm);
874 if (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1)) {
875 ah->aspm_enabled = true;
876 /* Initialize PCIe PM and SERDES registers. */
877 ath9k_hw_configpcipowersave(ah, false);
878 ath_info(common, "ASPM enabled: 0x%x\n", aspm);
879 }
880 }
881
882 static const struct ath_bus_ops ath_pci_bus_ops = {
883 .ath_bus_type = ATH_PCI,
884 .read_cachesize = ath_pci_read_cachesize,
885 .eeprom_read = ath_pci_eeprom_read,
886 .aspm_init = ath_pci_aspm_init,
887 };
888
ath_pci_probe(struct pci_dev * pdev,const struct pci_device_id * id)889 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
890 {
891 struct ath_softc *sc;
892 struct ieee80211_hw *hw;
893 u8 csz;
894 u32 val;
895 int ret = 0;
896 char hw_name[64];
897
898 if (pcim_enable_device(pdev))
899 return -EIO;
900
901 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
902 if (ret) {
903 pr_err("32-bit DMA not available\n");
904 return ret;
905 }
906
907 ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
908 if (ret) {
909 pr_err("32-bit DMA consistent DMA enable failed\n");
910 return ret;
911 }
912
913 /*
914 * Cache line size is used to size and align various
915 * structures used to communicate with the hardware.
916 */
917 pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &csz);
918 if (csz == 0) {
919 /*
920 * Linux 2.4.18 (at least) writes the cache line size
921 * register as a 16-bit wide register which is wrong.
922 * We must have this setup properly for rx buffer
923 * DMA to work so force a reasonable value here if it
924 * comes up zero.
925 */
926 csz = L1_CACHE_BYTES / sizeof(u32);
927 pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, csz);
928 }
929 /*
930 * The default setting of latency timer yields poor results,
931 * set it to the value used by other systems. It may be worth
932 * tweaking this setting more.
933 */
934 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xa8);
935
936 pci_set_master(pdev);
937
938 /*
939 * Disable the RETRY_TIMEOUT register (0x41) to keep
940 * PCI Tx retries from interfering with C3 CPU state.
941 */
942 pci_read_config_dword(pdev, 0x40, &val);
943 if ((val & 0x0000ff00) != 0)
944 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
945
946 ret = pcim_iomap_regions(pdev, BIT(0), "ath9k");
947 if (ret) {
948 dev_err(&pdev->dev, "PCI memory region reserve error\n");
949 return -ENODEV;
950 }
951
952 ath9k_fill_chanctx_ops();
953 hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
954 if (!hw) {
955 dev_err(&pdev->dev, "No memory for ieee80211_hw\n");
956 return -ENOMEM;
957 }
958
959 SET_IEEE80211_DEV(hw, &pdev->dev);
960 pci_set_drvdata(pdev, hw);
961
962 sc = hw->priv;
963 sc->hw = hw;
964 sc->dev = &pdev->dev;
965 sc->mem = pcim_iomap_table(pdev)[0];
966 sc->driver_data = id->driver_data;
967
968 ret = request_irq(pdev->irq, ath_isr, IRQF_SHARED, "ath9k", sc);
969 if (ret) {
970 dev_err(&pdev->dev, "request_irq failed\n");
971 goto err_irq;
972 }
973
974 sc->irq = pdev->irq;
975
976 ret = ath9k_init_device(id->device, sc, &ath_pci_bus_ops);
977 if (ret) {
978 dev_err(&pdev->dev, "Failed to initialize device\n");
979 goto err_init;
980 }
981
982 ath9k_hw_name(sc->sc_ah, hw_name, sizeof(hw_name));
983 wiphy_info(hw->wiphy, "%s mem=0x%lx, irq=%d\n",
984 hw_name, (unsigned long)sc->mem, pdev->irq);
985
986 return 0;
987
988 err_init:
989 free_irq(sc->irq, sc);
990 err_irq:
991 ieee80211_free_hw(hw);
992 return ret;
993 }
994
ath_pci_remove(struct pci_dev * pdev)995 static void ath_pci_remove(struct pci_dev *pdev)
996 {
997 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
998 struct ath_softc *sc = hw->priv;
999
1000 if (!is_ath9k_unloaded)
1001 sc->sc_ah->ah_flags |= AH_UNPLUGGED;
1002 ath9k_deinit_device(sc);
1003 free_irq(sc->irq, sc);
1004 ieee80211_free_hw(sc->hw);
1005 }
1006
1007 #ifdef CONFIG_PM_SLEEP
1008
ath_pci_suspend(struct device * device)1009 static int ath_pci_suspend(struct device *device)
1010 {
1011 struct pci_dev *pdev = to_pci_dev(device);
1012 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
1013 struct ath_softc *sc = hw->priv;
1014 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1015
1016 if (test_bit(ATH_OP_WOW_ENABLED, &common->op_flags)) {
1017 dev_info(&pdev->dev, "WOW is enabled, bypassing PCI suspend\n");
1018 return 0;
1019 }
1020
1021 /* The device has to be moved to FULLSLEEP forcibly.
1022 * Otherwise the chip never moved to full sleep,
1023 * when no interface is up.
1024 */
1025 ath9k_stop_btcoex(sc);
1026 ath9k_hw_disable(sc->sc_ah);
1027 del_timer_sync(&sc->sleep_timer);
1028 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
1029
1030 return 0;
1031 }
1032
ath_pci_resume(struct device * device)1033 static int ath_pci_resume(struct device *device)
1034 {
1035 struct pci_dev *pdev = to_pci_dev(device);
1036 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
1037 struct ath_softc *sc = hw->priv;
1038 struct ath_hw *ah = sc->sc_ah;
1039 struct ath_common *common = ath9k_hw_common(ah);
1040 u32 val;
1041
1042 /*
1043 * Suspend/Resume resets the PCI configuration space, so we have to
1044 * re-disable the RETRY_TIMEOUT register (0x41) to keep
1045 * PCI Tx retries from interfering with C3 CPU state
1046 */
1047 pci_read_config_dword(pdev, 0x40, &val);
1048 if ((val & 0x0000ff00) != 0)
1049 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
1050
1051 ath_pci_aspm_init(common);
1052 ah->reset_power_on = false;
1053
1054 return 0;
1055 }
1056
1057 static SIMPLE_DEV_PM_OPS(ath9k_pm_ops, ath_pci_suspend, ath_pci_resume);
1058
1059 #define ATH9K_PM_OPS (&ath9k_pm_ops)
1060
1061 #else /* !CONFIG_PM_SLEEP */
1062
1063 #define ATH9K_PM_OPS NULL
1064
1065 #endif /* !CONFIG_PM_SLEEP */
1066
1067
1068 MODULE_DEVICE_TABLE(pci, ath_pci_id_table);
1069
1070 static struct pci_driver ath_pci_driver = {
1071 .name = "ath9k",
1072 .id_table = ath_pci_id_table,
1073 .probe = ath_pci_probe,
1074 .remove = ath_pci_remove,
1075 .driver.pm = ATH9K_PM_OPS,
1076 };
1077
ath_pci_init(void)1078 int ath_pci_init(void)
1079 {
1080 return pci_register_driver(&ath_pci_driver);
1081 }
1082
ath_pci_exit(void)1083 void ath_pci_exit(void)
1084 {
1085 pci_unregister_driver(&ath_pci_driver);
1086 }
1087