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 DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table
) = {
27 { PCI_VDEVICE(ATHEROS
, 0x0023) }, /* PCI */
28 { PCI_VDEVICE(ATHEROS
, 0x0024) }, /* PCI-E */
29 { PCI_VDEVICE(ATHEROS
, 0x0027) }, /* PCI */
30 { PCI_VDEVICE(ATHEROS
, 0x0029) }, /* PCI */
31 { PCI_VDEVICE(ATHEROS
, 0x002A) }, /* PCI-E */
33 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
37 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
38 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
40 PCI_VENDOR_ID_FOXCONN
,
42 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
43 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
47 .driver_data
= ATH9K_PCI_D3_L1_WAR
},
48 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
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
},
79 /* AR9285 card for Asus */
80 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
84 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
86 { PCI_VDEVICE(ATHEROS
, 0x002B) }, /* PCI-E */
87 { PCI_VDEVICE(ATHEROS
, 0x002C) }, /* PCI-E 802.11n bonded out */
88 { PCI_VDEVICE(ATHEROS
, 0x002D) }, /* PCI */
89 { PCI_VDEVICE(ATHEROS
, 0x002E) }, /* PCI-E */
91 /* Killer Wireless (3x3) */
92 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
96 .driver_data
= ATH9K_PCI_KILLER
},
97 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
101 .driver_data
= ATH9K_PCI_KILLER
},
103 { PCI_VDEVICE(ATHEROS
, 0x0030) }, /* PCI-E AR9300 */
106 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
108 PCI_VENDOR_ID_AZWAVE
,
110 .driver_data
= ATH9K_PCI_CUS198
| ATH9K_PCI_BT_ANT_DIV
},
111 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
113 PCI_VENDOR_ID_AZWAVE
,
115 .driver_data
= ATH9K_PCI_CUS198
| ATH9K_PCI_BT_ANT_DIV
},
116 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
118 PCI_VENDOR_ID_AZWAVE
,
120 .driver_data
= ATH9K_PCI_CUS198
| ATH9K_PCI_BT_ANT_DIV
},
121 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
123 PCI_VENDOR_ID_AZWAVE
,
125 .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_CUS230
| ATH9K_PCI_BT_ANT_DIV
},
133 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
135 PCI_VENDOR_ID_FOXCONN
,
137 .driver_data
= ATH9K_PCI_CUS230
| ATH9K_PCI_BT_ANT_DIV
},
140 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
142 PCI_VENDOR_ID_ATHEROS
,
144 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
145 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
147 PCI_VENDOR_ID_ATHEROS
,
149 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
150 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
154 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
155 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
159 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
160 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
162 PCI_VENDOR_ID_SAMSUNG
,
164 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
165 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
167 PCI_VENDOR_ID_SAMSUNG
,
169 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
170 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
172 PCI_VENDOR_ID_SAMSUNG
,
174 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
175 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
177 PCI_VENDOR_ID_SAMSUNG
,
179 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
180 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
182 PCI_VENDOR_ID_SAMSUNG
,
184 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
185 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
187 PCI_VENDOR_ID_SAMSUNG
,
189 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
190 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
192 PCI_VENDOR_ID_SAMSUNG
,
194 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
195 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
197 PCI_VENDOR_ID_SAMSUNG
,
199 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
200 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
202 PCI_VENDOR_ID_LENOVO
,
204 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
205 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
207 PCI_VENDOR_ID_LENOVO
,
209 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
211 /* AR9485 cards with PLL power-save disabled by default. */
212 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
214 PCI_VENDOR_ID_AZWAVE
,
216 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
217 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
219 PCI_VENDOR_ID_AZWAVE
,
221 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
222 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
226 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
227 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
231 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
232 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
236 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
237 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
239 PCI_VENDOR_ID_FOXCONN
,
241 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
242 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
244 PCI_VENDOR_ID_FOXCONN
,
246 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
247 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
251 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
252 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
256 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
257 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
261 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
262 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
264 PCI_VENDOR_ID_AZWAVE
,
266 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
267 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
269 PCI_VENDOR_ID_AZWAVE
,
271 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
272 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
274 PCI_VENDOR_ID_AZWAVE
,
276 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
277 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
279 PCI_VENDOR_ID_AZWAVE
,
281 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
282 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
286 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
287 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
291 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
292 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
294 PCI_VENDOR_ID_ASUSTEK
,
296 .driver_data
= ATH9K_PCI_NO_PLL_PWRSAVE
},
298 { PCI_VDEVICE(ATHEROS
, 0x0032) }, /* PCI-E AR9485 */
299 { PCI_VDEVICE(ATHEROS
, 0x0033) }, /* PCI-E AR9580 */
302 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
304 PCI_VENDOR_ID_AZWAVE
,
306 .driver_data
= ATH9K_PCI_CUS217
},
307 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
311 .driver_data
= ATH9K_PCI_CUS217
},
313 /* AR9462 with WoW support */
314 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
316 PCI_VENDOR_ID_ATHEROS
,
318 .driver_data
= ATH9K_PCI_WOW
},
319 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
321 PCI_VENDOR_ID_LENOVO
,
323 .driver_data
= ATH9K_PCI_WOW
},
324 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
326 PCI_VENDOR_ID_ATTANSIC
,
328 .driver_data
= ATH9K_PCI_WOW
},
329 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
331 PCI_VENDOR_ID_AZWAVE
,
333 .driver_data
= ATH9K_PCI_WOW
},
334 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
336 PCI_VENDOR_ID_ASUSTEK
,
338 .driver_data
= ATH9K_PCI_WOW
},
339 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
343 .driver_data
= ATH9K_PCI_WOW
},
344 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
348 .driver_data
= ATH9K_PCI_WOW
},
349 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
353 .driver_data
= ATH9K_PCI_WOW
},
354 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
358 .driver_data
= ATH9K_PCI_WOW
},
359 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
363 .driver_data
= ATH9K_PCI_WOW
},
364 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
366 0x10CF, /* Fujitsu */
368 .driver_data
= ATH9K_PCI_WOW
},
370 /* Killer Wireless (2x2) */
371 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
375 .driver_data
= ATH9K_PCI_KILLER
},
377 { PCI_VDEVICE(ATHEROS
, 0x0034) }, /* PCI-E AR9462 */
378 { PCI_VDEVICE(ATHEROS
, 0x0037) }, /* PCI-E AR1111/AR9485 */
381 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
383 PCI_VENDOR_ID_ATHEROS
,
385 .driver_data
= ATH9K_PCI_CUS252
|
386 ATH9K_PCI_AR9565_2ANT
|
387 ATH9K_PCI_BT_ANT_DIV
},
388 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
390 PCI_VENDOR_ID_AZWAVE
,
392 .driver_data
= ATH9K_PCI_CUS252
|
393 ATH9K_PCI_AR9565_2ANT
|
394 ATH9K_PCI_BT_ANT_DIV
},
397 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
399 PCI_VENDOR_ID_FOXCONN
,
401 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
402 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
406 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
407 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
411 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
412 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
416 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
417 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
421 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
422 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
426 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
427 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
431 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
432 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
436 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
437 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
441 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
442 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
444 PCI_VENDOR_ID_AZWAVE
,
446 .driver_data
= ATH9K_PCI_AR9565_1ANT
},
448 /* WB335 1-ANT / Antenna Diversity */
449 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
451 PCI_VENDOR_ID_ATHEROS
,
453 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
454 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
456 PCI_VENDOR_ID_ATHEROS
,
458 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
459 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
461 PCI_VENDOR_ID_ATHEROS
,
463 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
464 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
466 PCI_VENDOR_ID_FOXCONN
,
468 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
469 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
473 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
474 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
478 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
479 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
483 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
484 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
488 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
489 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
493 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
494 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
498 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
499 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
501 PCI_VENDOR_ID_AZWAVE
,
503 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
504 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
508 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
509 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
513 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
514 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
518 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
519 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
523 .driver_data
= ATH9K_PCI_AR9565_1ANT
| ATH9K_PCI_BT_ANT_DIV
},
525 /* WB335 2-ANT / Antenna-Diversity */
526 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
528 PCI_VENDOR_ID_SAMSUNG
,
530 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
531 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
533 PCI_VENDOR_ID_SAMSUNG
,
535 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
536 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
538 PCI_VENDOR_ID_SAMSUNG
,
540 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
541 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
543 PCI_VENDOR_ID_SAMSUNG
,
545 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
546 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
548 PCI_VENDOR_ID_SAMSUNG
,
550 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
551 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
553 PCI_VENDOR_ID_ATHEROS
,
555 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
556 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
558 PCI_VENDOR_ID_ATHEROS
,
560 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
561 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
565 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
566 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
570 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
571 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
575 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
576 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
580 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
581 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
585 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
586 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
588 PCI_VENDOR_ID_AZWAVE
,
590 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
591 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
593 PCI_VENDOR_ID_AZWAVE
,
595 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
596 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
598 PCI_VENDOR_ID_AZWAVE
,
600 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
601 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
605 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
606 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
610 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
611 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
615 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
616 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
620 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
621 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
625 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
626 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
628 PCI_VENDOR_ID_FOXCONN
,
630 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
631 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
633 PCI_VENDOR_ID_FOXCONN
,
635 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
636 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
638 PCI_VENDOR_ID_LENOVO
,
640 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
641 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
643 PCI_VENDOR_ID_LENOVO
,
645 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
646 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
648 PCI_VENDOR_ID_ASUSTEK
,
650 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
651 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS
,
655 .driver_data
= ATH9K_PCI_AR9565_2ANT
| ATH9K_PCI_BT_ANT_DIV
},
657 /* PCI-E AR9565 (WB335) */
658 { PCI_VDEVICE(ATHEROS
, 0x0036),
659 .driver_data
= ATH9K_PCI_BT_ANT_DIV
},
665 /* return bus cachesize in 4B word units */
666 static void ath_pci_read_cachesize(struct ath_common
*common
, int *csz
)
668 struct ath_softc
*sc
= (struct ath_softc
*) common
->priv
;
671 pci_read_config_byte(to_pci_dev(sc
->dev
), PCI_CACHE_LINE_SIZE
, &u8tmp
);
675 * This check was put in to avoid "unpleasant" consequences if
676 * the bootrom has not fully initialized all PCI devices.
677 * Sometimes the cache line size register is not set
681 *csz
= DEFAULT_CACHELINE
>> 2; /* Use the default size */
684 static bool ath_pci_eeprom_read(struct ath_common
*common
, u32 off
, u16
*data
)
686 struct ath_softc
*sc
= (struct ath_softc
*) common
->priv
;
687 struct ath9k_platform_data
*pdata
= sc
->dev
->platform_data
;
690 if (off
>= (ARRAY_SIZE(pdata
->eeprom_data
))) {
692 "%s: eeprom read failed, offset %08x is out of range\n",
696 *data
= pdata
->eeprom_data
[off
];
698 struct ath_hw
*ah
= (struct ath_hw
*) common
->ah
;
700 common
->ops
->read(ah
, AR5416_EEPROM_OFFSET
+
701 (off
<< AR5416_EEPROM_S
));
703 if (!ath9k_hw_wait(ah
,
704 AR_EEPROM_STATUS_DATA
,
705 AR_EEPROM_STATUS_DATA_BUSY
|
706 AR_EEPROM_STATUS_DATA_PROT_ACCESS
, 0,
711 *data
= MS(common
->ops
->read(ah
, AR_EEPROM_STATUS_DATA
),
712 AR_EEPROM_STATUS_DATA_VAL
);
718 /* Need to be called after we discover btcoex capabilities */
719 static void ath_pci_aspm_init(struct ath_common
*common
)
721 struct ath_softc
*sc
= (struct ath_softc
*) common
->priv
;
722 struct ath_hw
*ah
= sc
->sc_ah
;
723 struct pci_dev
*pdev
= to_pci_dev(sc
->dev
);
724 struct pci_dev
*parent
;
727 if (!ah
->is_pciexpress
)
730 parent
= pdev
->bus
->self
;
734 if ((ath9k_hw_get_btcoex_scheme(ah
) != ATH_BTCOEX_CFG_NONE
) &&
735 (AR_SREV_9285(ah
))) {
736 /* Bluetooth coexistence requires disabling ASPM. */
737 pcie_capability_clear_word(pdev
, PCI_EXP_LNKCTL
,
738 PCI_EXP_LNKCTL_ASPM_L0S
| PCI_EXP_LNKCTL_ASPM_L1
);
741 * Both upstream and downstream PCIe components should
742 * have the same ASPM settings.
744 pcie_capability_clear_word(parent
, PCI_EXP_LNKCTL
,
745 PCI_EXP_LNKCTL_ASPM_L0S
| PCI_EXP_LNKCTL_ASPM_L1
);
747 ath_info(common
, "Disabling ASPM since BTCOEX is enabled\n");
752 * 0x70c - Ack Frequency Register.
754 * Bits 27:29 - DEFAULT_L1_ENTRANCE_LATENCY.
764 if (AR_SREV_9462(ah
))
765 pci_read_config_dword(pdev
, 0x70c, &ah
->config
.aspm_l1_fix
);
767 pcie_capability_read_word(parent
, PCI_EXP_LNKCTL
, &aspm
);
768 if (aspm
& (PCI_EXP_LNKCTL_ASPM_L0S
| PCI_EXP_LNKCTL_ASPM_L1
)) {
769 ah
->aspm_enabled
= true;
770 /* Initialize PCIe PM and SERDES registers. */
771 ath9k_hw_configpcipowersave(ah
, false);
772 ath_info(common
, "ASPM enabled: 0x%x\n", aspm
);
776 static const struct ath_bus_ops ath_pci_bus_ops
= {
777 .ath_bus_type
= ATH_PCI
,
778 .read_cachesize
= ath_pci_read_cachesize
,
779 .eeprom_read
= ath_pci_eeprom_read
,
780 .aspm_init
= ath_pci_aspm_init
,
783 static int ath_pci_probe(struct pci_dev
*pdev
, const struct pci_device_id
*id
)
785 struct ath_softc
*sc
;
786 struct ieee80211_hw
*hw
;
792 if (pcim_enable_device(pdev
))
795 ret
= pci_set_dma_mask(pdev
, DMA_BIT_MASK(32));
797 pr_err("32-bit DMA not available\n");
801 ret
= pci_set_consistent_dma_mask(pdev
, DMA_BIT_MASK(32));
803 pr_err("32-bit DMA consistent DMA enable failed\n");
808 * Cache line size is used to size and align various
809 * structures used to communicate with the hardware.
811 pci_read_config_byte(pdev
, PCI_CACHE_LINE_SIZE
, &csz
);
814 * Linux 2.4.18 (at least) writes the cache line size
815 * register as a 16-bit wide register which is wrong.
816 * We must have this setup properly for rx buffer
817 * DMA to work so force a reasonable value here if it
820 csz
= L1_CACHE_BYTES
/ sizeof(u32
);
821 pci_write_config_byte(pdev
, PCI_CACHE_LINE_SIZE
, csz
);
824 * The default setting of latency timer yields poor results,
825 * set it to the value used by other systems. It may be worth
826 * tweaking this setting more.
828 pci_write_config_byte(pdev
, PCI_LATENCY_TIMER
, 0xa8);
830 pci_set_master(pdev
);
833 * Disable the RETRY_TIMEOUT register (0x41) to keep
834 * PCI Tx retries from interfering with C3 CPU state.
836 pci_read_config_dword(pdev
, 0x40, &val
);
837 if ((val
& 0x0000ff00) != 0)
838 pci_write_config_dword(pdev
, 0x40, val
& 0xffff00ff);
840 ret
= pcim_iomap_regions(pdev
, BIT(0), "ath9k");
842 dev_err(&pdev
->dev
, "PCI memory region reserve error\n");
846 hw
= ieee80211_alloc_hw(sizeof(struct ath_softc
), &ath9k_ops
);
848 dev_err(&pdev
->dev
, "No memory for ieee80211_hw\n");
852 SET_IEEE80211_DEV(hw
, &pdev
->dev
);
853 pci_set_drvdata(pdev
, hw
);
857 sc
->dev
= &pdev
->dev
;
858 sc
->mem
= pcim_iomap_table(pdev
)[0];
859 sc
->driver_data
= id
->driver_data
;
861 /* Will be cleared in ath9k_start() */
862 set_bit(SC_OP_INVALID
, &sc
->sc_flags
);
864 ret
= request_irq(pdev
->irq
, ath_isr
, IRQF_SHARED
, "ath9k", sc
);
866 dev_err(&pdev
->dev
, "request_irq failed\n");
872 ret
= ath9k_init_device(id
->device
, sc
, &ath_pci_bus_ops
);
874 dev_err(&pdev
->dev
, "Failed to initialize device\n");
878 ath9k_hw_name(sc
->sc_ah
, hw_name
, sizeof(hw_name
));
879 wiphy_info(hw
->wiphy
, "%s mem=0x%lx, irq=%d\n",
880 hw_name
, (unsigned long)sc
->mem
, pdev
->irq
);
885 free_irq(sc
->irq
, sc
);
887 ieee80211_free_hw(hw
);
891 static void ath_pci_remove(struct pci_dev
*pdev
)
893 struct ieee80211_hw
*hw
= pci_get_drvdata(pdev
);
894 struct ath_softc
*sc
= hw
->priv
;
896 if (!is_ath9k_unloaded
)
897 sc
->sc_ah
->ah_flags
|= AH_UNPLUGGED
;
898 ath9k_deinit_device(sc
);
899 free_irq(sc
->irq
, sc
);
900 ieee80211_free_hw(sc
->hw
);
903 #ifdef CONFIG_PM_SLEEP
905 static int ath_pci_suspend(struct device
*device
)
907 struct pci_dev
*pdev
= to_pci_dev(device
);
908 struct ieee80211_hw
*hw
= pci_get_drvdata(pdev
);
909 struct ath_softc
*sc
= hw
->priv
;
914 /* The device has to be moved to FULLSLEEP forcibly.
915 * Otherwise the chip never moved to full sleep,
916 * when no interface is up.
918 ath9k_stop_btcoex(sc
);
919 ath9k_hw_disable(sc
->sc_ah
);
920 ath9k_hw_setpower(sc
->sc_ah
, ATH9K_PM_FULL_SLEEP
);
925 static int ath_pci_resume(struct device
*device
)
927 struct pci_dev
*pdev
= to_pci_dev(device
);
928 struct ieee80211_hw
*hw
= pci_get_drvdata(pdev
);
929 struct ath_softc
*sc
= hw
->priv
;
930 struct ath_hw
*ah
= sc
->sc_ah
;
931 struct ath_common
*common
= ath9k_hw_common(ah
);
935 * Suspend/Resume resets the PCI configuration space, so we have to
936 * re-disable the RETRY_TIMEOUT register (0x41) to keep
937 * PCI Tx retries from interfering with C3 CPU state
939 pci_read_config_dword(pdev
, 0x40, &val
);
940 if ((val
& 0x0000ff00) != 0)
941 pci_write_config_dword(pdev
, 0x40, val
& 0xffff00ff);
943 ath_pci_aspm_init(common
);
944 ah
->reset_power_on
= false;
949 static SIMPLE_DEV_PM_OPS(ath9k_pm_ops
, ath_pci_suspend
, ath_pci_resume
);
951 #define ATH9K_PM_OPS (&ath9k_pm_ops)
953 #else /* !CONFIG_PM_SLEEP */
955 #define ATH9K_PM_OPS NULL
957 #endif /* !CONFIG_PM_SLEEP */
960 MODULE_DEVICE_TABLE(pci
, ath_pci_id_table
);
962 static struct pci_driver ath_pci_driver
= {
964 .id_table
= ath_pci_id_table
,
965 .probe
= ath_pci_probe
,
966 .remove
= ath_pci_remove
,
967 .driver
.pm
= ATH9K_PM_OPS
,
970 int ath_pci_init(void)
972 return pci_register_driver(&ath_pci_driver
);
975 void ath_pci_exit(void)
977 pci_unregister_driver(&ath_pci_driver
);