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