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