pci.c 29 KB

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