Version:  2.0.40 2.2.26 2.4.37 3.13 3.14 3.15 3.16 3.17 3.18 3.19 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10

Linux/drivers/net/wireless/ath/ath9k/pci.c

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

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us