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