2 * Copyright (c) 2008-2011 Atheros Communications Inc.
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.
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.
17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19 #include <linux/nl80211.h>
20 #include <linux/pci.h>
21 #include <linux/pci-aspm.h>
22 #include <linux/module.h>
25 extern int ath9k_use_msi
;
27 static const struct pci_device_id ath_pci_id_table
[] = {
28 { PCI_VDEVICE(ATHEROS
, 0x0023) }, /* PCI */
29 { PCI_VDEVICE(ATHEROS
, 0x0024) }, /* PCI-E */
30 { PCI_VDEVICE(ATHEROS
, 0x0027) }, /* PCI */
32 #ifdef CONFIG_ATH9K_PCOEM
33 /* Mini PCI AR9220 MB92 cards: Compex WLM200NX, Wistron DNMA-92 */
34 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
36 PCI_VENDOR_ID_ATHEROS
,
38 .driver_data
= ATH9K_PCI_LED_ACT_HI
},
41 { PCI_VDEVICE(ATHEROS
, 0x0029) }, /* PCI */
43 #ifdef CONFIG_ATH9K_PCOEM
44 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
48 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
49 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
51 PCI_VENDOR_ID_FOXCONN
,
53 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
54 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
58 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
59 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
63 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
64 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
68 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
69 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
73 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
74 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
78 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
79 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
83 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
84 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
88 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
91 { PCI_VDEVICE(ATHEROS
, 0x002A) }, /* PCI-E */
93 #ifdef CONFIG_ATH9K_PCOEM
94 /* AR9285 card for Asus */
95 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
99 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
102 { PCI_VDEVICE(ATHEROS
, 0x002B) }, /* PCI-E */
103 { PCI_VDEVICE(ATHEROS
, 0x002C) }, /* PCI-E 802.11n bonded out */
104 { PCI_VDEVICE(ATHEROS
, 0x002D) }, /* PCI */
105 { PCI_VDEVICE(ATHEROS
, 0x002E) }, /* PCI-E */
107 /* Killer Wireless (3x3) */
108 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
112 .driver_data
= ATH9K_PCI_KILLER
},
113 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
117 .driver_data
= ATH9K_PCI_KILLER
},
119 { PCI_VDEVICE(ATHEROS
, 0x0030) }, /* PCI-E AR9300 */
121 #ifdef CONFIG_ATH9K_PCOEM
123 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
125 PCI_VENDOR_ID_AZWAVE
,
127 .driver_data
= ATH9K_PCI_CUS198
| ATH9K_PCI_BT_ANT_DIV
},
128 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
130 PCI_VENDOR_ID_AZWAVE
,
132 .driver_data
= ATH9K_PCI_CUS198
| ATH9K_PCI_BT_ANT_DIV
},
133 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
135 PCI_VENDOR_ID_AZWAVE
,
137 .driver_data
= ATH9K_PCI_CUS198
| ATH9K_PCI_BT_ANT_DIV
},
138 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
140 PCI_VENDOR_ID_AZWAVE
,
142 .driver_data
= ATH9K_PCI_CUS198
| ATH9K_PCI_BT_ANT_DIV
},
145 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
147 PCI_VENDOR_ID_AZWAVE
,
149 .driver_data
= ATH9K_PCI_CUS230
| ATH9K_PCI_BT_ANT_DIV
},
150 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
152 PCI_VENDOR_ID_FOXCONN
,
154 .driver_data
= ATH9K_PCI_CUS230
| ATH9K_PCI_BT_ANT_DIV
},
157 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
159 PCI_VENDOR_ID_ATHEROS
,
161 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
162 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
164 PCI_VENDOR_ID_ATHEROS
,
166 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
167 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
171 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
172 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
176 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
177 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
179 PCI_VENDOR_ID_SAMSUNG
,
181 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
182 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
184 PCI_VENDOR_ID_SAMSUNG
,
186 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
187 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
189 PCI_VENDOR_ID_SAMSUNG
,
191 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
192 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
194 PCI_VENDOR_ID_SAMSUNG
,
196 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
197 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
199 PCI_VENDOR_ID_SAMSUNG
,
201 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
202 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
204 PCI_VENDOR_ID_SAMSUNG
,
206 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
207 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
209 PCI_VENDOR_ID_SAMSUNG
,
211 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
212 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
214 PCI_VENDOR_ID_SAMSUNG
,
216 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
217 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
219 PCI_VENDOR_ID_LENOVO
,
221 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
222 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
224 PCI_VENDOR_ID_LENOVO
,
226 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
228 /* AR9485 cards with PLL power-save disabled by default. */
229 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
231 PCI_VENDOR_ID_AZWAVE
,
233 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
234 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
236 PCI_VENDOR_ID_AZWAVE
,
238 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
239 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
243 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
244 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
248 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
249 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
253 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
254 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
256 PCI_VENDOR_ID_FOXCONN
,
258 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
259 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
261 PCI_VENDOR_ID_FOXCONN
,
263 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
264 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
268 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
269 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
273 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
274 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
278 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
279 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
281 PCI_VENDOR_ID_AZWAVE
,
283 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
284 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
286 PCI_VENDOR_ID_AZWAVE
,
288 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
289 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
291 PCI_VENDOR_ID_AZWAVE
,
293 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
294 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
296 PCI_VENDOR_ID_AZWAVE
,
298 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
299 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
303 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
304 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
308 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
309 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
311 PCI_VENDOR_ID_ASUSTEK
,
313 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
316 { PCI_VDEVICE(ATHEROS
, 0x0032) }, /* PCI-E AR9485 */
317 { PCI_VDEVICE(ATHEROS
, 0x0033) }, /* PCI-E AR9580 */
319 #ifdef CONFIG_ATH9K_PCOEM
321 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
323 PCI_VENDOR_ID_AZWAVE
,
325 .driver_data
= ATH9K_PCI_CUS217
},
326 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
330 .driver_data
= ATH9K_PCI_CUS217
},
332 /* AR9462 with WoW support */
333 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
335 PCI_VENDOR_ID_ATHEROS
,
337 .driver_data
= ATH9K_PCI_WOW
},
338 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
340 PCI_VENDOR_ID_LENOVO
,
342 .driver_data
= ATH9K_PCI_WOW
},
343 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
345 PCI_VENDOR_ID_ATTANSIC
,
347 .driver_data
= ATH9K_PCI_WOW
},
348 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
350 PCI_VENDOR_ID_AZWAVE
,
352 .driver_data
= ATH9K_PCI_WOW
},
353 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
355 PCI_VENDOR_ID_ASUSTEK
,
357 .driver_data
= ATH9K_PCI_WOW
},
358 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
362 .driver_data
= ATH9K_PCI_WOW
},
363 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
367 .driver_data
= ATH9K_PCI_WOW
},
368 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
372 .driver_data
= ATH9K_PCI_WOW
},
373 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
377 .driver_data
= ATH9K_PCI_WOW
},
378 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
382 .driver_data
= ATH9K_PCI_WOW
},
383 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
385 0x10CF, /* Fujitsu */
387 .driver_data
= ATH9K_PCI_WOW
},
388 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
392 .driver_data
= ATH9K_PCI_WOW
},
393 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
397 .driver_data
= ATH9K_PCI_WOW
},
399 /* Killer Wireless (2x2) */
400 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
404 .driver_data
= ATH9K_PCI_KILLER
},
406 { PCI_VDEVICE(ATHEROS
, 0x0034) }, /* PCI-E AR9462 */
407 { PCI_VDEVICE(ATHEROS
, 0x0037) }, /* PCI-E AR1111/AR9485 */
410 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
412 PCI_VENDOR_ID_ATHEROS
,
414 .driver_data
= ATH9K_PCI_CUS252
|
415 ATH9K_PCI_AR9565_2ANT
|
416 ATH9K_PCI_BT_ANT_DIV
},
417 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
419 PCI_VENDOR_ID_AZWAVE
,
421 .driver_data
= ATH9K_PCI_CUS252
|
422 ATH9K_PCI_AR9565_2ANT
|
423 ATH9K_PCI_BT_ANT_DIV
},
426 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
428 PCI_VENDOR_ID_FOXCONN
,
430 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
431 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
435 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
436 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
440 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
441 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
445 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
446 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
450 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
451 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
455 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
456 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
460 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
461 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
465 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
466 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
470 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
471 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
475 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
476 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
480 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
481 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
483 PCI_VENDOR_ID_AZWAVE
,
485 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
486 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
488 PCI_VENDOR_ID_AZWAVE
,
490 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
492 /* WB335 1-ANT / Antenna Diversity */
493 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
495 PCI_VENDOR_ID_ATHEROS
,
497 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
498 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
500 PCI_VENDOR_ID_ATHEROS
,
502 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
503 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
505 PCI_VENDOR_ID_ATHEROS
,
507 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
508 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
510 PCI_VENDOR_ID_FOXCONN
,
512 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
513 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
517 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
518 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
522 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
523 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
527 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
528 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
532 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
533 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
537 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
538 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
542 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
543 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
545 PCI_VENDOR_ID_AZWAVE
,
547 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
548 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
550 PCI_VENDOR_ID_AZWAVE
,
552 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
553 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
557 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
558 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
562 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
563 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
567 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
568 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
572 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
574 /* WB335 2-ANT / Antenna-Diversity */
575 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
577 PCI_VENDOR_ID_SAMSUNG
,
579 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
580 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
582 PCI_VENDOR_ID_SAMSUNG
,
584 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
585 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
587 PCI_VENDOR_ID_SAMSUNG
,
589 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
590 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
592 PCI_VENDOR_ID_SAMSUNG
,
594 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
595 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
597 PCI_VENDOR_ID_SAMSUNG
,
599 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
600 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
602 PCI_VENDOR_ID_SAMSUNG
,
604 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
605 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
607 PCI_VENDOR_ID_SAMSUNG
,
609 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
610 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
612 PCI_VENDOR_ID_ATHEROS
,
614 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
615 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
617 PCI_VENDOR_ID_ATHEROS
,
619 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
620 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
624 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
625 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
629 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
630 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
634 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
635 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
639 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
640 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
644 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
645 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
649 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
650 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
654 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
655 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
659 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
660 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
662 PCI_VENDOR_ID_AZWAVE
,
664 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
665 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
667 PCI_VENDOR_ID_AZWAVE
,
669 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
670 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
672 PCI_VENDOR_ID_AZWAVE
,
674 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
675 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
677 PCI_VENDOR_ID_AZWAVE
,
679 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
680 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
682 PCI_VENDOR_ID_AZWAVE
,
684 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
685 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
687 PCI_VENDOR_ID_AZWAVE
,
689 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
690 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
694 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
695 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
699 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
700 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
704 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
705 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
709 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
710 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
714 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
715 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
719 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
720 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
724 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
725 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
727 PCI_VENDOR_ID_FOXCONN
,
729 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
730 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
732 PCI_VENDOR_ID_FOXCONN
,
734 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
735 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
737 PCI_VENDOR_ID_FOXCONN
,
739 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
740 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
742 PCI_VENDOR_ID_FOXCONN
,
744 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
745 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
747 PCI_VENDOR_ID_FOXCONN
,
749 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
750 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
752 PCI_VENDOR_ID_LENOVO
,
754 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
755 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
757 PCI_VENDOR_ID_LENOVO
,
759 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
760 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
762 PCI_VENDOR_ID_ASUSTEK
,
764 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
765 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
769 .driver_data
= ATH9K_PCI_AR9565_2ANT
|
770 ATH9K_PCI_BT_ANT_DIV
|
771 ATH9K_PCI_LED_ACT_HI
},
773 /* PCI-E AR9565 (WB335) */
774 { PCI_VDEVICE(ATHEROS
, 0x0036),
775 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
782 /* return bus cachesize in 4B word units */
783 static void ath_pci_read_cachesize(struct ath_common
*common
, int *csz
)
785 struct ath_softc
*sc
= (struct ath_softc
*) common
->priv
;
788 pci_read_config_byte(to_pci_dev(sc
->dev
), PCI_CACHE_LINE_SIZE
, &u8tmp
);
792 * This check was put in to avoid "unpleasant" consequences if
793 * the bootrom has not fully initialized all PCI devices.
794 * Sometimes the cache line size register is not set
798 *csz
= DEFAULT_CACHELINE
>> 2; /* Use the default size */
801 static bool ath_pci_eeprom_read(struct ath_common
*common
, u32 off
, u16
*data
)
803 struct ath_hw
*ah
= (struct ath_hw
*) common
->ah
;
805 common
->ops
->read(ah
, AR5416_EEPROM_OFFSET
+ (off
<< AR5416_EEPROM_S
));
807 if (!ath9k_hw_wait(ah
,
808 AR_EEPROM_STATUS_DATA
,
809 AR_EEPROM_STATUS_DATA_BUSY
|
810 AR_EEPROM_STATUS_DATA_PROT_ACCESS
, 0,
815 *data
= MS(common
->ops
->read(ah
, AR_EEPROM_STATUS_DATA
),
816 AR_EEPROM_STATUS_DATA_VAL
);
821 /* Need to be called after we discover btcoex capabilities */
822 static void ath_pci_aspm_init(struct ath_common
*common
)
824 struct ath_softc
*sc
= (struct ath_softc
*) common
->priv
;
825 struct ath_hw
*ah
= sc
->sc_ah
;
826 struct pci_dev
*pdev
= to_pci_dev(sc
->dev
);
827 struct pci_dev
*parent
;
830 if (!ah
->is_pciexpress
)
833 parent
= pdev
->bus
->self
;
837 if ((ath9k_hw_get_btcoex_scheme(ah
) != ATH_BTCOEX_CFG_NONE
) &&
838 (AR_SREV_9285(ah
))) {
839 /* Bluetooth coexistence requires disabling ASPM. */
840 pcie_capability_clear_word(pdev
, PCI_EXP_LNKCTL
,
841 PCI_EXP_LNKCTL_ASPM_L0S
| PCI_EXP_LNKCTL_ASPM_L1
);
844 * Both upstream and downstream PCIe components should
845 * have the same ASPM settings.
847 pcie_capability_clear_word(parent
, PCI_EXP_LNKCTL
,
848 PCI_EXP_LNKCTL_ASPM_L0S
| PCI_EXP_LNKCTL_ASPM_L1
);
850 ath_info(common
, "Disabling ASPM since BTCOEX is enabled\n");
855 * 0x70c - Ack Frequency Register.
857 * Bits 27:29 - DEFAULT_L1_ENTRANCE_LATENCY.
867 if (AR_SREV_9462(ah
))
868 pci_read_config_dword(pdev
, 0x70c, &ah
->config
.aspm_l1_fix
);
870 pcie_capability_read_word(parent
, PCI_EXP_LNKCTL
, &aspm
);
871 if (aspm
& (PCI_EXP_LNKCTL_ASPM_L0S
| PCI_EXP_LNKCTL_ASPM_L1
)) {
872 ah
->aspm_enabled
= true;
873 /* Initialize PCIe PM and SERDES registers. */
874 ath9k_hw_configpcipowersave(ah
, false);
875 ath_info(common
, "ASPM enabled: 0x%x\n", aspm
);
879 static const struct ath_bus_ops ath_pci_bus_ops
= {
880 .ath_bus_type
= ATH_PCI
,
881 .read_cachesize
= ath_pci_read_cachesize
,
882 .eeprom_read
= ath_pci_eeprom_read
,
883 .aspm_init
= ath_pci_aspm_init
,
886 static int ath_pci_probe(struct pci_dev
*pdev
, const struct pci_device_id
*id
)
888 struct ath_softc
*sc
;
889 struct ieee80211_hw
*hw
;
896 if (pcim_enable_device(pdev
))
899 ret
= pci_set_dma_mask(pdev
, DMA_BIT_MASK(32));
901 pr_err("32-bit DMA not available\n");
905 ret
= pci_set_consistent_dma_mask(pdev
, DMA_BIT_MASK(32));
907 pr_err("32-bit DMA consistent DMA enable failed\n");
912 * Cache line size is used to size and align various
913 * structures used to communicate with the hardware.
915 pci_read_config_byte(pdev
, PCI_CACHE_LINE_SIZE
, &csz
);
918 * Linux 2.4.18 (at least) writes the cache line size
919 * register as a 16-bit wide register which is wrong.
920 * We must have this setup properly for rx buffer
921 * DMA to work so force a reasonable value here if it
924 csz
= L1_CACHE_BYTES
/ sizeof(u32
);
925 pci_write_config_byte(pdev
, PCI_CACHE_LINE_SIZE
, csz
);
928 * The default setting of latency timer yields poor results,
929 * set it to the value used by other systems. It may be worth
930 * tweaking this setting more.
932 pci_write_config_byte(pdev
, PCI_LATENCY_TIMER
, 0xa8);
934 pci_set_master(pdev
);
937 * Disable the RETRY_TIMEOUT register (0x41) to keep
938 * PCI Tx retries from interfering with C3 CPU state.
940 pci_read_config_dword(pdev
, 0x40, &val
);
941 if ((val
& 0x0000ff00) != 0)
942 pci_write_config_dword(pdev
, 0x40, val
& 0xffff00ff);
944 ret
= pcim_iomap_regions(pdev
, BIT(0), "ath9k");
946 dev_err(&pdev
->dev
, "PCI memory region reserve error\n");
950 ath9k_fill_chanctx_ops();
951 hw
= ieee80211_alloc_hw(sizeof(struct ath_softc
), &ath9k_ops
);
953 dev_err(&pdev
->dev
, "No memory for ieee80211_hw\n");
957 SET_IEEE80211_DEV(hw
, &pdev
->dev
);
958 pci_set_drvdata(pdev
, hw
);
962 sc
->dev
= &pdev
->dev
;
963 sc
->mem
= pcim_iomap_table(pdev
)[0];
964 sc
->driver_data
= id
->driver_data
;
967 if (pci_enable_msi(pdev
) == 0) {
969 dev_err(&pdev
->dev
, "Using MSI\n");
971 dev_err(&pdev
->dev
, "Using INTx\n");
976 ret
= request_irq(pdev
->irq
, ath_isr
, IRQF_SHARED
, "ath9k", sc
);
978 ret
= request_irq(pdev
->irq
, ath_isr
, 0, "ath9k", sc
);
981 dev_err(&pdev
->dev
, "request_irq failed\n");
987 ret
= ath9k_init_device(id
->device
, sc
, &ath_pci_bus_ops
);
989 dev_err(&pdev
->dev
, "Failed to initialize device\n");
993 sc
->sc_ah
->msi_enabled
= msi_enabled
;
994 sc
->sc_ah
->msi_reg
= 0;
996 ath9k_hw_name(sc
->sc_ah
, hw_name
, sizeof(hw_name
));
997 wiphy_info(hw
->wiphy
, "%s mem=0x%lx, irq=%d\n",
998 hw_name
, (unsigned long)sc
->mem
, pdev
->irq
);
1003 free_irq(sc
->irq
, sc
);
1005 ieee80211_free_hw(hw
);
1009 static void ath_pci_remove(struct pci_dev
*pdev
)
1011 struct ieee80211_hw
*hw
= pci_get_drvdata(pdev
);
1012 struct ath_softc
*sc
= hw
->priv
;
1014 if (!is_ath9k_unloaded
)
1015 sc
->sc_ah
->ah_flags
|= AH_UNPLUGGED
;
1016 ath9k_deinit_device(sc
);
1017 free_irq(sc
->irq
, sc
);
1018 ieee80211_free_hw(sc
->hw
);
1021 #ifdef CONFIG_PM_SLEEP
1023 static int ath_pci_suspend(struct device
*device
)
1025 struct pci_dev
*pdev
= to_pci_dev(device
);
1026 struct ieee80211_hw
*hw
= pci_get_drvdata(pdev
);
1027 struct ath_softc
*sc
= hw
->priv
;
1028 struct ath_common
*common
= ath9k_hw_common(sc
->sc_ah
);
1030 if (test_bit(ATH_OP_WOW_ENABLED
, &common
->op_flags
)) {
1031 dev_info(&pdev
->dev
, "WOW is enabled, bypassing PCI suspend\n");
1035 /* The device has to be moved to FULLSLEEP forcibly.
1036 * Otherwise the chip never moved to full sleep,
1037 * when no interface is up.
1039 ath9k_stop_btcoex(sc
);
1040 ath9k_hw_disable(sc
->sc_ah
);
1041 del_timer_sync(&sc
->sleep_timer
);
1042 ath9k_hw_setpower(sc
->sc_ah
, ATH9K_PM_FULL_SLEEP
);
1047 static int ath_pci_resume(struct device
*device
)
1049 struct pci_dev
*pdev
= to_pci_dev(device
);
1050 struct ieee80211_hw
*hw
= pci_get_drvdata(pdev
);
1051 struct ath_softc
*sc
= hw
->priv
;
1052 struct ath_hw
*ah
= sc
->sc_ah
;
1053 struct ath_common
*common
= ath9k_hw_common(ah
);
1057 * Suspend/Resume resets the PCI configuration space, so we have to
1058 * re-disable the RETRY_TIMEOUT register (0x41) to keep
1059 * PCI Tx retries from interfering with C3 CPU state
1061 pci_read_config_dword(pdev
, 0x40, &val
);
1062 if ((val
& 0x0000ff00) != 0)
1063 pci_write_config_dword(pdev
, 0x40, val
& 0xffff00ff);
1065 ath_pci_aspm_init(common
);
1066 ah
->reset_power_on
= false;
1071 static SIMPLE_DEV_PM_OPS(ath9k_pm_ops
, ath_pci_suspend
, ath_pci_resume
);
1073 #define ATH9K_PM_OPS (&ath9k_pm_ops)
1075 #else /* !CONFIG_PM_SLEEP */
1077 #define ATH9K_PM_OPS NULL
1079 #endif /* !CONFIG_PM_SLEEP */
1082 MODULE_DEVICE_TABLE(pci
, ath_pci_id_table
);
1084 static struct pci_driver ath_pci_driver
= {
1086 .id_table
= ath_pci_id_table
,
1087 .probe
= ath_pci_probe
,
1088 .remove
= ath_pci_remove
,
1089 .driver
.pm
= ATH9K_PM_OPS
,
1092 int ath_pci_init(void)
1094 return pci_register_driver(&ath_pci_driver
);
1097 void ath_pci_exit(void)
1099 pci_unregister_driver(&ath_pci_driver
);