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