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/ath9k_platform.h>
23 #include <linux/module.h>
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 */
31 #ifdef CONFIG_ATH9K_PCOEM
32 /* Mini PCI AR9220 MB92 cards: Compex WLM200NX, Wistron DNMA-92 */
33 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
35 PCI_VENDOR_ID_ATHEROS
,
37 .driver_data
= ATH9K_PCI_LED_ACT_HI
},
40 { PCI_VDEVICE(ATHEROS
, 0x0029) }, /* PCI */
42 #ifdef CONFIG_ATH9K_PCOEM
43 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
47 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
48 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
50 PCI_VENDOR_ID_FOXCONN
,
52 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
53 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
57 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
58 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
62 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
63 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
67 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
68 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
72 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
73 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
77 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
78 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
82 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
83 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
87 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
90 { PCI_VDEVICE(ATHEROS
, 0x002A) }, /* PCI-E */
92 #ifdef CONFIG_ATH9K_PCOEM
93 /* AR9285 card for Asus */
94 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
98 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
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 */
106 /* Killer Wireless (3x3) */
107 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
111 .driver_data
= ATH9K_PCI_KILLER
},
112 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
116 .driver_data
= ATH9K_PCI_KILLER
},
118 { PCI_VDEVICE(ATHEROS
, 0x0030) }, /* PCI-E AR9300 */
120 #ifdef CONFIG_ATH9K_PCOEM
122 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
124 PCI_VENDOR_ID_AZWAVE
,
126 .driver_data
= ATH9K_PCI_CUS198
| ATH9K_PCI_BT_ANT_DIV
},
127 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
129 PCI_VENDOR_ID_AZWAVE
,
131 .driver_data
= ATH9K_PCI_CUS198
| ATH9K_PCI_BT_ANT_DIV
},
132 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
134 PCI_VENDOR_ID_AZWAVE
,
136 .driver_data
= ATH9K_PCI_CUS198
| ATH9K_PCI_BT_ANT_DIV
},
137 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
139 PCI_VENDOR_ID_AZWAVE
,
141 .driver_data
= ATH9K_PCI_CUS198
| ATH9K_PCI_BT_ANT_DIV
},
144 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
146 PCI_VENDOR_ID_AZWAVE
,
148 .driver_data
= ATH9K_PCI_CUS230
| ATH9K_PCI_BT_ANT_DIV
},
149 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
151 PCI_VENDOR_ID_FOXCONN
,
153 .driver_data
= ATH9K_PCI_CUS230
| ATH9K_PCI_BT_ANT_DIV
},
156 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
158 PCI_VENDOR_ID_ATHEROS
,
160 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
161 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
163 PCI_VENDOR_ID_ATHEROS
,
165 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
166 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
170 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
171 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
175 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
176 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
178 PCI_VENDOR_ID_SAMSUNG
,
180 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
181 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
183 PCI_VENDOR_ID_SAMSUNG
,
185 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
186 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
188 PCI_VENDOR_ID_SAMSUNG
,
190 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
191 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
193 PCI_VENDOR_ID_SAMSUNG
,
195 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
196 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
198 PCI_VENDOR_ID_SAMSUNG
,
200 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
201 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
203 PCI_VENDOR_ID_SAMSUNG
,
205 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
206 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
208 PCI_VENDOR_ID_SAMSUNG
,
210 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
211 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
213 PCI_VENDOR_ID_SAMSUNG
,
215 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
216 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
218 PCI_VENDOR_ID_LENOVO
,
220 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
221 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
223 PCI_VENDOR_ID_LENOVO
,
225 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
227 /* AR9485 cards with PLL power-save disabled by default. */
228 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
230 PCI_VENDOR_ID_AZWAVE
,
232 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
233 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
235 PCI_VENDOR_ID_AZWAVE
,
237 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
238 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
242 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
243 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
247 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
248 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
252 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
253 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
255 PCI_VENDOR_ID_FOXCONN
,
257 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
258 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
260 PCI_VENDOR_ID_FOXCONN
,
262 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
263 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
267 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
268 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
272 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
273 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
277 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
278 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
280 PCI_VENDOR_ID_AZWAVE
,
282 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
283 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
285 PCI_VENDOR_ID_AZWAVE
,
287 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
288 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
290 PCI_VENDOR_ID_AZWAVE
,
292 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
293 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
295 PCI_VENDOR_ID_AZWAVE
,
297 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
298 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
302 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
303 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
307 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
308 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
310 PCI_VENDOR_ID_ASUSTEK
,
312 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
315 { PCI_VDEVICE(ATHEROS
, 0x0032) }, /* PCI-E AR9485 */
316 { PCI_VDEVICE(ATHEROS
, 0x0033) }, /* PCI-E AR9580 */
318 #ifdef CONFIG_ATH9K_PCOEM
320 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
322 PCI_VENDOR_ID_AZWAVE
,
324 .driver_data
= ATH9K_PCI_CUS217
},
325 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
329 .driver_data
= ATH9K_PCI_CUS217
},
331 /* AR9462 with WoW support */
332 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
334 PCI_VENDOR_ID_ATHEROS
,
336 .driver_data
= ATH9K_PCI_WOW
},
337 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
339 PCI_VENDOR_ID_LENOVO
,
341 .driver_data
= ATH9K_PCI_WOW
},
342 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
344 PCI_VENDOR_ID_ATTANSIC
,
346 .driver_data
= ATH9K_PCI_WOW
},
347 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
349 PCI_VENDOR_ID_AZWAVE
,
351 .driver_data
= ATH9K_PCI_WOW
},
352 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
354 PCI_VENDOR_ID_ASUSTEK
,
356 .driver_data
= ATH9K_PCI_WOW
},
357 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
361 .driver_data
= ATH9K_PCI_WOW
},
362 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
366 .driver_data
= ATH9K_PCI_WOW
},
367 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
371 .driver_data
= ATH9K_PCI_WOW
},
372 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
376 .driver_data
= ATH9K_PCI_WOW
},
377 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
381 .driver_data
= ATH9K_PCI_WOW
},
382 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
384 0x10CF, /* Fujitsu */
386 .driver_data
= ATH9K_PCI_WOW
},
388 /* Killer Wireless (2x2) */
389 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
393 .driver_data
= ATH9K_PCI_KILLER
},
395 { PCI_VDEVICE(ATHEROS
, 0x0034) }, /* PCI-E AR9462 */
396 { PCI_VDEVICE(ATHEROS
, 0x0037) }, /* PCI-E AR1111/AR9485 */
399 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
401 PCI_VENDOR_ID_ATHEROS
,
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
,
408 PCI_VENDOR_ID_AZWAVE
,
410 .driver_data
= ATH9K_PCI_CUS252
|
411 ATH9K_PCI_AR9565_2ANT
|
412 ATH9K_PCI_BT_ANT_DIV
},
415 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
417 PCI_VENDOR_ID_FOXCONN
,
419 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
420 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
424 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
425 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
429 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
430 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
434 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
435 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
439 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
440 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
444 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
445 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
449 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
450 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
454 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
455 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
459 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
460 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
464 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
465 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
469 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
470 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
472 PCI_VENDOR_ID_AZWAVE
,
474 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
475 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
477 PCI_VENDOR_ID_AZWAVE
,
479 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
481 /* WB335 1-ANT / Antenna Diversity */
482 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
484 PCI_VENDOR_ID_ATHEROS
,
486 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
487 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
489 PCI_VENDOR_ID_ATHEROS
,
491 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
492 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
494 PCI_VENDOR_ID_ATHEROS
,
496 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
497 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
499 PCI_VENDOR_ID_FOXCONN
,
501 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
502 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
506 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
507 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
511 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
512 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
516 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
517 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
521 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
522 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
526 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
527 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
531 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
532 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
534 PCI_VENDOR_ID_AZWAVE
,
536 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
537 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
539 PCI_VENDOR_ID_AZWAVE
,
541 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
542 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
546 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
547 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
551 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
552 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
556 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
557 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
561 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
563 /* WB335 2-ANT / Antenna-Diversity */
564 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
566 PCI_VENDOR_ID_SAMSUNG
,
568 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
569 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
571 PCI_VENDOR_ID_SAMSUNG
,
573 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
574 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
576 PCI_VENDOR_ID_SAMSUNG
,
578 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
579 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
581 PCI_VENDOR_ID_SAMSUNG
,
583 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
584 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
586 PCI_VENDOR_ID_SAMSUNG
,
588 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
589 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
591 PCI_VENDOR_ID_SAMSUNG
,
593 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
594 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
596 PCI_VENDOR_ID_SAMSUNG
,
598 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
599 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
601 PCI_VENDOR_ID_ATHEROS
,
603 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
604 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
606 PCI_VENDOR_ID_ATHEROS
,
608 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
609 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
613 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
614 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
618 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
619 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
623 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
624 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
628 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
629 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
633 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
634 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
638 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
639 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
643 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
644 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
648 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
649 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
651 PCI_VENDOR_ID_AZWAVE
,
653 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
654 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
656 PCI_VENDOR_ID_AZWAVE
,
658 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
659 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
661 PCI_VENDOR_ID_AZWAVE
,
663 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
664 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
666 PCI_VENDOR_ID_AZWAVE
,
668 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
669 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
671 PCI_VENDOR_ID_AZWAVE
,
673 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
674 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
676 PCI_VENDOR_ID_AZWAVE
,
678 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
679 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
683 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
684 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
688 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
689 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
693 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
694 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
698 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
699 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
703 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
704 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
708 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
709 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
713 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
714 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
716 PCI_VENDOR_ID_FOXCONN
,
718 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
719 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
721 PCI_VENDOR_ID_FOXCONN
,
723 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
724 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
726 PCI_VENDOR_ID_FOXCONN
,
728 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
729 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
731 PCI_VENDOR_ID_FOXCONN
,
733 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
734 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
736 PCI_VENDOR_ID_FOXCONN
,
738 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
739 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
741 PCI_VENDOR_ID_LENOVO
,
743 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
744 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
746 PCI_VENDOR_ID_LENOVO
,
748 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
749 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
751 PCI_VENDOR_ID_ASUSTEK
,
753 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
754 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
758 .driver_data
= ATH9K_PCI_AR9565_2ANT
|
759 ATH9K_PCI_BT_ANT_DIV
|
760 ATH9K_PCI_LED_ACT_HI
},
762 /* PCI-E AR9565 (WB335) */
763 { PCI_VDEVICE(ATHEROS
, 0x0036),
764 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
771 /* return bus cachesize in 4B word units */
772 static void ath_pci_read_cachesize(struct ath_common
*common
, int *csz
)
774 struct ath_softc
*sc
= (struct ath_softc
*) common
->priv
;
777 pci_read_config_byte(to_pci_dev(sc
->dev
), PCI_CACHE_LINE_SIZE
, &u8tmp
);
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
787 *csz
= DEFAULT_CACHELINE
>> 2; /* Use the default size */
790 static bool ath_pci_eeprom_read(struct ath_common
*common
, u32 off
, u16
*data
)
792 struct ath_softc
*sc
= (struct ath_softc
*) common
->priv
;
793 struct ath9k_platform_data
*pdata
= sc
->dev
->platform_data
;
795 if (pdata
&& !pdata
->use_eeprom
) {
796 if (off
>= (ARRAY_SIZE(pdata
->eeprom_data
))) {
798 "%s: eeprom read failed, offset %08x is out of range\n",
802 *data
= pdata
->eeprom_data
[off
];
804 struct ath_hw
*ah
= (struct ath_hw
*) common
->ah
;
806 common
->ops
->read(ah
, AR5416_EEPROM_OFFSET
+
807 (off
<< AR5416_EEPROM_S
));
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,
817 *data
= MS(common
->ops
->read(ah
, AR_EEPROM_STATUS_DATA
),
818 AR_EEPROM_STATUS_DATA_VAL
);
824 /* Need to be called after we discover btcoex capabilities */
825 static void ath_pci_aspm_init(struct ath_common
*common
)
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
;
833 if (!ah
->is_pciexpress
)
836 parent
= pdev
->bus
->self
;
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
);
847 * Both upstream and downstream PCIe components should
848 * have the same ASPM settings.
850 pcie_capability_clear_word(parent
, PCI_EXP_LNKCTL
,
851 PCI_EXP_LNKCTL_ASPM_L0S
| PCI_EXP_LNKCTL_ASPM_L1
);
853 ath_info(common
, "Disabling ASPM since BTCOEX is enabled\n");
858 * 0x70c - Ack Frequency Register.
860 * Bits 27:29 - DEFAULT_L1_ENTRANCE_LATENCY.
870 if (AR_SREV_9462(ah
))
871 pci_read_config_dword(pdev
, 0x70c, &ah
->config
.aspm_l1_fix
);
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
);
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
,
889 static int ath_pci_probe(struct pci_dev
*pdev
, const struct pci_device_id
*id
)
891 struct ath_softc
*sc
;
892 struct ieee80211_hw
*hw
;
898 if (pcim_enable_device(pdev
))
901 ret
= pci_set_dma_mask(pdev
, DMA_BIT_MASK(32));
903 pr_err("32-bit DMA not available\n");
907 ret
= pci_set_consistent_dma_mask(pdev
, DMA_BIT_MASK(32));
909 pr_err("32-bit DMA consistent DMA enable failed\n");
914 * Cache line size is used to size and align various
915 * structures used to communicate with the hardware.
917 pci_read_config_byte(pdev
, PCI_CACHE_LINE_SIZE
, &csz
);
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
926 csz
= L1_CACHE_BYTES
/ sizeof(u32
);
927 pci_write_config_byte(pdev
, PCI_CACHE_LINE_SIZE
, csz
);
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.
934 pci_write_config_byte(pdev
, PCI_LATENCY_TIMER
, 0xa8);
936 pci_set_master(pdev
);
939 * Disable the RETRY_TIMEOUT register (0x41) to keep
940 * PCI Tx retries from interfering with C3 CPU state.
942 pci_read_config_dword(pdev
, 0x40, &val
);
943 if ((val
& 0x0000ff00) != 0)
944 pci_write_config_dword(pdev
, 0x40, val
& 0xffff00ff);
946 ret
= pcim_iomap_regions(pdev
, BIT(0), "ath9k");
948 dev_err(&pdev
->dev
, "PCI memory region reserve error\n");
952 ath9k_fill_chanctx_ops();
953 hw
= ieee80211_alloc_hw(sizeof(struct ath_softc
), &ath9k_ops
);
955 dev_err(&pdev
->dev
, "No memory for ieee80211_hw\n");
959 SET_IEEE80211_DEV(hw
, &pdev
->dev
);
960 pci_set_drvdata(pdev
, hw
);
964 sc
->dev
= &pdev
->dev
;
965 sc
->mem
= pcim_iomap_table(pdev
)[0];
966 sc
->driver_data
= id
->driver_data
;
968 ret
= request_irq(pdev
->irq
, ath_isr
, IRQF_SHARED
, "ath9k", sc
);
970 dev_err(&pdev
->dev
, "request_irq failed\n");
976 ret
= ath9k_init_device(id
->device
, sc
, &ath_pci_bus_ops
);
978 dev_err(&pdev
->dev
, "Failed to initialize device\n");
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
);
989 free_irq(sc
->irq
, sc
);
991 ieee80211_free_hw(hw
);
995 static void ath_pci_remove(struct pci_dev
*pdev
)
997 struct ieee80211_hw
*hw
= pci_get_drvdata(pdev
);
998 struct ath_softc
*sc
= hw
->priv
;
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
);
1007 #ifdef CONFIG_PM_SLEEP
1009 static int ath_pci_suspend(struct device
*device
)
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
);
1016 if (test_bit(ATH_OP_WOW_ENABLED
, &common
->op_flags
)) {
1017 dev_info(&pdev
->dev
, "WOW is enabled, bypassing PCI suspend\n");
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.
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
);
1033 static int ath_pci_resume(struct device
*device
)
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
);
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
1047 pci_read_config_dword(pdev
, 0x40, &val
);
1048 if ((val
& 0x0000ff00) != 0)
1049 pci_write_config_dword(pdev
, 0x40, val
& 0xffff00ff);
1051 ath_pci_aspm_init(common
);
1052 ah
->reset_power_on
= false;
1057 static SIMPLE_DEV_PM_OPS(ath9k_pm_ops
, ath_pci_suspend
, ath_pci_resume
);
1059 #define ATH9K_PM_OPS (&ath9k_pm_ops)
1061 #else /* !CONFIG_PM_SLEEP */
1063 #define ATH9K_PM_OPS NULL
1065 #endif /* !CONFIG_PM_SLEEP */
1068 MODULE_DEVICE_TABLE(pci
, ath_pci_id_table
);
1070 static struct pci_driver ath_pci_driver
= {
1072 .id_table
= ath_pci_id_table
,
1073 .probe
= ath_pci_probe
,
1074 .remove
= ath_pci_remove
,
1075 .driver
.pm
= ATH9K_PM_OPS
,
1078 int ath_pci_init(void)
1080 return pci_register_driver(&ath_pci_driver
);
1083 void ath_pci_exit(void)
1085 pci_unregister_driver(&ath_pci_driver
);