hw.h 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  1. /*
  2. * Copyright (c) 2008 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. #ifndef HW_H
  17. #define HW_H
  18. #include <linux/if_ether.h>
  19. #include <linux/delay.h>
  20. extern const struct hal_percal_data iq_cal_multi_sample;
  21. extern const struct hal_percal_data iq_cal_single_sample;
  22. extern const struct hal_percal_data adc_gain_cal_multi_sample;
  23. extern const struct hal_percal_data adc_gain_cal_single_sample;
  24. extern const struct hal_percal_data adc_dc_cal_multi_sample;
  25. extern const struct hal_percal_data adc_dc_cal_single_sample;
  26. extern const struct hal_percal_data adc_init_dc_cal;
  27. struct ar5416_desc {
  28. u32 ds_link;
  29. u32 ds_data;
  30. u32 ds_ctl0;
  31. u32 ds_ctl1;
  32. union {
  33. struct {
  34. u32 ctl2;
  35. u32 ctl3;
  36. u32 ctl4;
  37. u32 ctl5;
  38. u32 ctl6;
  39. u32 ctl7;
  40. u32 ctl8;
  41. u32 ctl9;
  42. u32 ctl10;
  43. u32 ctl11;
  44. u32 status0;
  45. u32 status1;
  46. u32 status2;
  47. u32 status3;
  48. u32 status4;
  49. u32 status5;
  50. u32 status6;
  51. u32 status7;
  52. u32 status8;
  53. u32 status9;
  54. } tx;
  55. struct {
  56. u32 status0;
  57. u32 status1;
  58. u32 status2;
  59. u32 status3;
  60. u32 status4;
  61. u32 status5;
  62. u32 status6;
  63. u32 status7;
  64. u32 status8;
  65. } rx;
  66. } u;
  67. } __packed;
  68. #define AR5416DESC(_ds) ((struct ar5416_desc *)(_ds))
  69. #define AR5416DESC_CONST(_ds) ((const struct ar5416_desc *)(_ds))
  70. #define ds_ctl2 u.tx.ctl2
  71. #define ds_ctl3 u.tx.ctl3
  72. #define ds_ctl4 u.tx.ctl4
  73. #define ds_ctl5 u.tx.ctl5
  74. #define ds_ctl6 u.tx.ctl6
  75. #define ds_ctl7 u.tx.ctl7
  76. #define ds_ctl8 u.tx.ctl8
  77. #define ds_ctl9 u.tx.ctl9
  78. #define ds_ctl10 u.tx.ctl10
  79. #define ds_ctl11 u.tx.ctl11
  80. #define ds_txstatus0 u.tx.status0
  81. #define ds_txstatus1 u.tx.status1
  82. #define ds_txstatus2 u.tx.status2
  83. #define ds_txstatus3 u.tx.status3
  84. #define ds_txstatus4 u.tx.status4
  85. #define ds_txstatus5 u.tx.status5
  86. #define ds_txstatus6 u.tx.status6
  87. #define ds_txstatus7 u.tx.status7
  88. #define ds_txstatus8 u.tx.status8
  89. #define ds_txstatus9 u.tx.status9
  90. #define ds_rxstatus0 u.rx.status0
  91. #define ds_rxstatus1 u.rx.status1
  92. #define ds_rxstatus2 u.rx.status2
  93. #define ds_rxstatus3 u.rx.status3
  94. #define ds_rxstatus4 u.rx.status4
  95. #define ds_rxstatus5 u.rx.status5
  96. #define ds_rxstatus6 u.rx.status6
  97. #define ds_rxstatus7 u.rx.status7
  98. #define ds_rxstatus8 u.rx.status8
  99. #define AR_FrameLen 0x00000fff
  100. #define AR_VirtMoreFrag 0x00001000
  101. #define AR_TxCtlRsvd00 0x0000e000
  102. #define AR_XmitPower 0x003f0000
  103. #define AR_XmitPower_S 16
  104. #define AR_RTSEnable 0x00400000
  105. #define AR_VEOL 0x00800000
  106. #define AR_ClrDestMask 0x01000000
  107. #define AR_TxCtlRsvd01 0x1e000000
  108. #define AR_TxIntrReq 0x20000000
  109. #define AR_DestIdxValid 0x40000000
  110. #define AR_CTSEnable 0x80000000
  111. #define AR_BufLen 0x00000fff
  112. #define AR_TxMore 0x00001000
  113. #define AR_DestIdx 0x000fe000
  114. #define AR_DestIdx_S 13
  115. #define AR_FrameType 0x00f00000
  116. #define AR_FrameType_S 20
  117. #define AR_NoAck 0x01000000
  118. #define AR_InsertTS 0x02000000
  119. #define AR_CorruptFCS 0x04000000
  120. #define AR_ExtOnly 0x08000000
  121. #define AR_ExtAndCtl 0x10000000
  122. #define AR_MoreAggr 0x20000000
  123. #define AR_IsAggr 0x40000000
  124. #define AR_BurstDur 0x00007fff
  125. #define AR_BurstDur_S 0
  126. #define AR_DurUpdateEna 0x00008000
  127. #define AR_XmitDataTries0 0x000f0000
  128. #define AR_XmitDataTries0_S 16
  129. #define AR_XmitDataTries1 0x00f00000
  130. #define AR_XmitDataTries1_S 20
  131. #define AR_XmitDataTries2 0x0f000000
  132. #define AR_XmitDataTries2_S 24
  133. #define AR_XmitDataTries3 0xf0000000
  134. #define AR_XmitDataTries3_S 28
  135. #define AR_XmitRate0 0x000000ff
  136. #define AR_XmitRate0_S 0
  137. #define AR_XmitRate1 0x0000ff00
  138. #define AR_XmitRate1_S 8
  139. #define AR_XmitRate2 0x00ff0000
  140. #define AR_XmitRate2_S 16
  141. #define AR_XmitRate3 0xff000000
  142. #define AR_XmitRate3_S 24
  143. #define AR_PacketDur0 0x00007fff
  144. #define AR_PacketDur0_S 0
  145. #define AR_RTSCTSQual0 0x00008000
  146. #define AR_PacketDur1 0x7fff0000
  147. #define AR_PacketDur1_S 16
  148. #define AR_RTSCTSQual1 0x80000000
  149. #define AR_PacketDur2 0x00007fff
  150. #define AR_PacketDur2_S 0
  151. #define AR_RTSCTSQual2 0x00008000
  152. #define AR_PacketDur3 0x7fff0000
  153. #define AR_PacketDur3_S 16
  154. #define AR_RTSCTSQual3 0x80000000
  155. #define AR_AggrLen 0x0000ffff
  156. #define AR_AggrLen_S 0
  157. #define AR_TxCtlRsvd60 0x00030000
  158. #define AR_PadDelim 0x03fc0000
  159. #define AR_PadDelim_S 18
  160. #define AR_EncrType 0x0c000000
  161. #define AR_EncrType_S 26
  162. #define AR_TxCtlRsvd61 0xf0000000
  163. #define AR_2040_0 0x00000001
  164. #define AR_GI0 0x00000002
  165. #define AR_ChainSel0 0x0000001c
  166. #define AR_ChainSel0_S 2
  167. #define AR_2040_1 0x00000020
  168. #define AR_GI1 0x00000040
  169. #define AR_ChainSel1 0x00000380
  170. #define AR_ChainSel1_S 7
  171. #define AR_2040_2 0x00000400
  172. #define AR_GI2 0x00000800
  173. #define AR_ChainSel2 0x00007000
  174. #define AR_ChainSel2_S 12
  175. #define AR_2040_3 0x00008000
  176. #define AR_GI3 0x00010000
  177. #define AR_ChainSel3 0x000e0000
  178. #define AR_ChainSel3_S 17
  179. #define AR_RTSCTSRate 0x0ff00000
  180. #define AR_RTSCTSRate_S 20
  181. #define AR_TxCtlRsvd70 0xf0000000
  182. #define AR_TxRSSIAnt00 0x000000ff
  183. #define AR_TxRSSIAnt00_S 0
  184. #define AR_TxRSSIAnt01 0x0000ff00
  185. #define AR_TxRSSIAnt01_S 8
  186. #define AR_TxRSSIAnt02 0x00ff0000
  187. #define AR_TxRSSIAnt02_S 16
  188. #define AR_TxStatusRsvd00 0x3f000000
  189. #define AR_TxBaStatus 0x40000000
  190. #define AR_TxStatusRsvd01 0x80000000
  191. #define AR_FrmXmitOK 0x00000001
  192. #define AR_ExcessiveRetries 0x00000002
  193. #define AR_FIFOUnderrun 0x00000004
  194. #define AR_Filtered 0x00000008
  195. #define AR_RTSFailCnt 0x000000f0
  196. #define AR_RTSFailCnt_S 4
  197. #define AR_DataFailCnt 0x00000f00
  198. #define AR_DataFailCnt_S 8
  199. #define AR_VirtRetryCnt 0x0000f000
  200. #define AR_VirtRetryCnt_S 12
  201. #define AR_TxDelimUnderrun 0x00010000
  202. #define AR_TxDataUnderrun 0x00020000
  203. #define AR_DescCfgErr 0x00040000
  204. #define AR_TxTimerExpired 0x00080000
  205. #define AR_TxStatusRsvd10 0xfff00000
  206. #define AR_SendTimestamp ds_txstatus2
  207. #define AR_BaBitmapLow ds_txstatus3
  208. #define AR_BaBitmapHigh ds_txstatus4
  209. #define AR_TxRSSIAnt10 0x000000ff
  210. #define AR_TxRSSIAnt10_S 0
  211. #define AR_TxRSSIAnt11 0x0000ff00
  212. #define AR_TxRSSIAnt11_S 8
  213. #define AR_TxRSSIAnt12 0x00ff0000
  214. #define AR_TxRSSIAnt12_S 16
  215. #define AR_TxRSSICombined 0xff000000
  216. #define AR_TxRSSICombined_S 24
  217. #define AR_TxEVM0 ds_txstatus5
  218. #define AR_TxEVM1 ds_txstatus6
  219. #define AR_TxEVM2 ds_txstatus7
  220. #define AR_TxDone 0x00000001
  221. #define AR_SeqNum 0x00001ffe
  222. #define AR_SeqNum_S 1
  223. #define AR_TxStatusRsvd80 0x0001e000
  224. #define AR_TxOpExceeded 0x00020000
  225. #define AR_TxStatusRsvd81 0x001c0000
  226. #define AR_FinalTxIdx 0x00600000
  227. #define AR_FinalTxIdx_S 21
  228. #define AR_TxStatusRsvd82 0x01800000
  229. #define AR_PowerMgmt 0x02000000
  230. #define AR_TxStatusRsvd83 0xfc000000
  231. #define AR_RxCTLRsvd00 0xffffffff
  232. #define AR_BufLen 0x00000fff
  233. #define AR_RxCtlRsvd00 0x00001000
  234. #define AR_RxIntrReq 0x00002000
  235. #define AR_RxCtlRsvd01 0xffffc000
  236. #define AR_RxRSSIAnt00 0x000000ff
  237. #define AR_RxRSSIAnt00_S 0
  238. #define AR_RxRSSIAnt01 0x0000ff00
  239. #define AR_RxRSSIAnt01_S 8
  240. #define AR_RxRSSIAnt02 0x00ff0000
  241. #define AR_RxRSSIAnt02_S 16
  242. #define AR_RxRate 0xff000000
  243. #define AR_RxRate_S 24
  244. #define AR_RxStatusRsvd00 0xff000000
  245. #define AR_DataLen 0x00000fff
  246. #define AR_RxMore 0x00001000
  247. #define AR_NumDelim 0x003fc000
  248. #define AR_NumDelim_S 14
  249. #define AR_RxStatusRsvd10 0xff800000
  250. #define AR_RcvTimestamp ds_rxstatus2
  251. #define AR_GI 0x00000001
  252. #define AR_2040 0x00000002
  253. #define AR_Parallel40 0x00000004
  254. #define AR_Parallel40_S 2
  255. #define AR_RxStatusRsvd30 0x000000f8
  256. #define AR_RxAntenna 0xffffff00
  257. #define AR_RxAntenna_S 8
  258. #define AR_RxRSSIAnt10 0x000000ff
  259. #define AR_RxRSSIAnt10_S 0
  260. #define AR_RxRSSIAnt11 0x0000ff00
  261. #define AR_RxRSSIAnt11_S 8
  262. #define AR_RxRSSIAnt12 0x00ff0000
  263. #define AR_RxRSSIAnt12_S 16
  264. #define AR_RxRSSICombined 0xff000000
  265. #define AR_RxRSSICombined_S 24
  266. #define AR_RxEVM0 ds_rxstatus4
  267. #define AR_RxEVM1 ds_rxstatus5
  268. #define AR_RxEVM2 ds_rxstatus6
  269. #define AR_RxDone 0x00000001
  270. #define AR_RxFrameOK 0x00000002
  271. #define AR_CRCErr 0x00000004
  272. #define AR_DecryptCRCErr 0x00000008
  273. #define AR_PHYErr 0x00000010
  274. #define AR_MichaelErr 0x00000020
  275. #define AR_PreDelimCRCErr 0x00000040
  276. #define AR_RxStatusRsvd70 0x00000080
  277. #define AR_RxKeyIdxValid 0x00000100
  278. #define AR_KeyIdx 0x0000fe00
  279. #define AR_KeyIdx_S 9
  280. #define AR_PHYErrCode 0x0000ff00
  281. #define AR_PHYErrCode_S 8
  282. #define AR_RxMoreAggr 0x00010000
  283. #define AR_RxAggr 0x00020000
  284. #define AR_PostDelimCRCErr 0x00040000
  285. #define AR_RxStatusRsvd71 0x3ff80000
  286. #define AR_DecryptBusyErr 0x40000000
  287. #define AR_KeyMiss 0x80000000
  288. #define AR5416_MAGIC 0x19641014
  289. #define RXSTATUS_RATE(ah, ads) (AR_SREV_5416_V20_OR_LATER(ah) ? \
  290. MS(ads->ds_rxstatus0, AR_RxRate) : \
  291. (ads->ds_rxstatus3 >> 2) & 0xFF)
  292. #define set11nTries(_series, _index) \
  293. (SM((_series)[_index].Tries, AR_XmitDataTries##_index))
  294. #define set11nRate(_series, _index) \
  295. (SM((_series)[_index].Rate, AR_XmitRate##_index))
  296. #define set11nPktDurRTSCTS(_series, _index) \
  297. (SM((_series)[_index].PktDuration, AR_PacketDur##_index) | \
  298. ((_series)[_index].RateFlags & ATH9K_RATESERIES_RTS_CTS ? \
  299. AR_RTSCTSQual##_index : 0))
  300. #define set11nRateFlags(_series, _index) \
  301. (((_series)[_index].RateFlags & ATH9K_RATESERIES_2040 ? \
  302. AR_2040_##_index : 0) \
  303. |((_series)[_index].RateFlags & ATH9K_RATESERIES_HALFGI ? \
  304. AR_GI##_index : 0) \
  305. |SM((_series)[_index].ChSel, AR_ChainSel##_index))
  306. #define AR_SREV_9100(ah) ((ah->ah_macVersion) == AR_SREV_VERSION_9100)
  307. #define INIT_CONFIG_STATUS 0x00000000
  308. #define INIT_RSSI_THR 0x00000700
  309. #define INIT_BCON_CNTRL_REG 0x00000000
  310. #define MIN_TX_FIFO_THRESHOLD 0x1
  311. #define MAX_TX_FIFO_THRESHOLD ((4096 / 64) - 1)
  312. #define INIT_TX_FIFO_THRESHOLD MIN_TX_FIFO_THRESHOLD
  313. struct ar5416AniState {
  314. struct ath9k_channel c;
  315. u8 noiseImmunityLevel;
  316. u8 spurImmunityLevel;
  317. u8 firstepLevel;
  318. u8 ofdmWeakSigDetectOff;
  319. u8 cckWeakSigThreshold;
  320. u32 listenTime;
  321. u32 ofdmTrigHigh;
  322. u32 ofdmTrigLow;
  323. int32_t cckTrigHigh;
  324. int32_t cckTrigLow;
  325. int32_t rssiThrLow;
  326. int32_t rssiThrHigh;
  327. u32 noiseFloor;
  328. u32 txFrameCount;
  329. u32 rxFrameCount;
  330. u32 cycleCount;
  331. u32 ofdmPhyErrCount;
  332. u32 cckPhyErrCount;
  333. u32 ofdmPhyErrBase;
  334. u32 cckPhyErrBase;
  335. int16_t pktRssi[2];
  336. int16_t ofdmErrRssi[2];
  337. int16_t cckErrRssi[2];
  338. };
  339. #define HAL_PROCESS_ANI 0x00000001
  340. #define DO_ANI(ah) \
  341. ((AH5416(ah)->ah_procPhyErr & HAL_PROCESS_ANI))
  342. struct ar5416Stats {
  343. u32 ast_ani_niup;
  344. u32 ast_ani_nidown;
  345. u32 ast_ani_spurup;
  346. u32 ast_ani_spurdown;
  347. u32 ast_ani_ofdmon;
  348. u32 ast_ani_ofdmoff;
  349. u32 ast_ani_cckhigh;
  350. u32 ast_ani_ccklow;
  351. u32 ast_ani_stepup;
  352. u32 ast_ani_stepdown;
  353. u32 ast_ani_ofdmerrs;
  354. u32 ast_ani_cckerrs;
  355. u32 ast_ani_reset;
  356. u32 ast_ani_lzero;
  357. u32 ast_ani_lneg;
  358. struct ath9k_mib_stats ast_mibstats;
  359. struct ath9k_node_stats ast_nodestats;
  360. };
  361. #define AR5416_OPFLAGS_11A 0x01
  362. #define AR5416_OPFLAGS_11G 0x02
  363. #define AR5416_OPFLAGS_N_5G_HT40 0x04
  364. #define AR5416_OPFLAGS_N_2G_HT40 0x08
  365. #define AR5416_OPFLAGS_N_5G_HT20 0x10
  366. #define AR5416_OPFLAGS_N_2G_HT20 0x20
  367. #define EEP_RFSILENT_ENABLED 0x0001
  368. #define EEP_RFSILENT_ENABLED_S 0
  369. #define EEP_RFSILENT_POLARITY 0x0002
  370. #define EEP_RFSILENT_POLARITY_S 1
  371. #define EEP_RFSILENT_GPIO_SEL 0x001c
  372. #define EEP_RFSILENT_GPIO_SEL_S 2
  373. #define AR5416_EEP_NO_BACK_VER 0x1
  374. #define AR5416_EEP_VER 0xE
  375. #define AR5416_EEP_VER_MINOR_MASK 0x0FFF
  376. #define AR5416_EEP_MINOR_VER_2 0x2
  377. #define AR5416_EEP_MINOR_VER_3 0x3
  378. #define AR5416_EEP_MINOR_VER_7 0x7
  379. #define AR5416_EEP_MINOR_VER_9 0x9
  380. #define AR5416_EEP_MINOR_VER_16 0x10
  381. #define AR5416_EEP_MINOR_VER_17 0x11
  382. #define AR5416_EEP_MINOR_VER_19 0x13
  383. #define AR5416_EEP_MINOR_VER_20 0x14
  384. #define AR5416_NUM_5G_CAL_PIERS 8
  385. #define AR5416_NUM_2G_CAL_PIERS 4
  386. #define AR5416_NUM_5G_20_TARGET_POWERS 8
  387. #define AR5416_NUM_5G_40_TARGET_POWERS 8
  388. #define AR5416_NUM_2G_CCK_TARGET_POWERS 3
  389. #define AR5416_NUM_2G_20_TARGET_POWERS 4
  390. #define AR5416_NUM_2G_40_TARGET_POWERS 4
  391. #define AR5416_NUM_CTLS 24
  392. #define AR5416_NUM_BAND_EDGES 8
  393. #define AR5416_NUM_PD_GAINS 4
  394. #define AR5416_PD_GAINS_IN_MASK 4
  395. #define AR5416_PD_GAIN_ICEPTS 5
  396. #define AR5416_EEPROM_MODAL_SPURS 5
  397. #define AR5416_MAX_RATE_POWER 63
  398. #define AR5416_NUM_PDADC_VALUES 128
  399. #define AR5416_BCHAN_UNUSED 0xFF
  400. #define AR5416_MAX_PWR_RANGE_IN_HALF_DB 64
  401. #define AR5416_MAX_CHAINS 3
  402. #define AR5416_PWR_TABLE_OFFSET -5
  403. /* Rx gain type values */
  404. #define AR5416_EEP_RXGAIN_23DB_BACKOFF 0
  405. #define AR5416_EEP_RXGAIN_13DB_BACKOFF 1
  406. #define AR5416_EEP_RXGAIN_ORIG 2
  407. /* Tx gain type values */
  408. #define AR5416_EEP_TXGAIN_ORIGINAL 0
  409. #define AR5416_EEP_TXGAIN_HIGH_POWER 1
  410. #define AR5416_EEP4K_START_LOC 64
  411. #define AR5416_EEP4K_NUM_2G_CAL_PIERS 3
  412. #define AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS 3
  413. #define AR5416_EEP4K_NUM_2G_20_TARGET_POWERS 3
  414. #define AR5416_EEP4K_NUM_2G_40_TARGET_POWERS 3
  415. #define AR5416_EEP4K_NUM_CTLS 12
  416. #define AR5416_EEP4K_NUM_BAND_EDGES 4
  417. #define AR5416_EEP4K_NUM_PD_GAINS 2
  418. #define AR5416_EEP4K_PD_GAINS_IN_MASK 4
  419. #define AR5416_EEP4K_PD_GAIN_ICEPTS 5
  420. #define AR5416_EEP4K_MAX_CHAINS 1
  421. enum eeprom_param {
  422. EEP_NFTHRESH_5,
  423. EEP_NFTHRESH_2,
  424. EEP_MAC_MSW,
  425. EEP_MAC_MID,
  426. EEP_MAC_LSW,
  427. EEP_REG_0,
  428. EEP_REG_1,
  429. EEP_OP_CAP,
  430. EEP_OP_MODE,
  431. EEP_RF_SILENT,
  432. EEP_OB_5,
  433. EEP_DB_5,
  434. EEP_OB_2,
  435. EEP_DB_2,
  436. EEP_MINOR_REV,
  437. EEP_TX_MASK,
  438. EEP_RX_MASK,
  439. EEP_RXGAIN_TYPE,
  440. EEP_TXGAIN_TYPE,
  441. EEP_DAC_HPWR_5G,
  442. };
  443. enum ar5416_rates {
  444. rate6mb, rate9mb, rate12mb, rate18mb,
  445. rate24mb, rate36mb, rate48mb, rate54mb,
  446. rate1l, rate2l, rate2s, rate5_5l,
  447. rate5_5s, rate11l, rate11s, rateXr,
  448. rateHt20_0, rateHt20_1, rateHt20_2, rateHt20_3,
  449. rateHt20_4, rateHt20_5, rateHt20_6, rateHt20_7,
  450. rateHt40_0, rateHt40_1, rateHt40_2, rateHt40_3,
  451. rateHt40_4, rateHt40_5, rateHt40_6, rateHt40_7,
  452. rateDupCck, rateDupOfdm, rateExtCck, rateExtOfdm,
  453. Ar5416RateSize
  454. };
  455. enum ath9k_hal_freq_band {
  456. ATH9K_HAL_FREQ_BAND_5GHZ = 0,
  457. ATH9K_HAL_FREQ_BAND_2GHZ = 1
  458. };
  459. struct base_eep_header {
  460. u16 length;
  461. u16 checksum;
  462. u16 version;
  463. u8 opCapFlags;
  464. u8 eepMisc;
  465. u16 regDmn[2];
  466. u8 macAddr[6];
  467. u8 rxMask;
  468. u8 txMask;
  469. u16 rfSilent;
  470. u16 blueToothOptions;
  471. u16 deviceCap;
  472. u32 binBuildNumber;
  473. u8 deviceType;
  474. u8 pwdclkind;
  475. u8 futureBase_1[2];
  476. u8 rxGainType;
  477. u8 dacHiPwrMode_5G;
  478. u8 futureBase_2;
  479. u8 dacLpMode;
  480. u8 txGainType;
  481. u8 rcChainMask;
  482. u8 desiredScaleCCK;
  483. u8 futureBase_3[23];
  484. } __packed;
  485. struct base_eep_header_4k {
  486. u16 length;
  487. u16 checksum;
  488. u16 version;
  489. u8 opCapFlags;
  490. u8 eepMisc;
  491. u16 regDmn[2];
  492. u8 macAddr[6];
  493. u8 rxMask;
  494. u8 txMask;
  495. u16 rfSilent;
  496. u16 blueToothOptions;
  497. u16 deviceCap;
  498. u32 binBuildNumber;
  499. u8 deviceType;
  500. u8 futureBase[1];
  501. } __packed;
  502. struct spur_chan {
  503. u16 spurChan;
  504. u8 spurRangeLow;
  505. u8 spurRangeHigh;
  506. } __packed;
  507. struct modal_eep_header {
  508. u32 antCtrlChain[AR5416_MAX_CHAINS];
  509. u32 antCtrlCommon;
  510. u8 antennaGainCh[AR5416_MAX_CHAINS];
  511. u8 switchSettling;
  512. u8 txRxAttenCh[AR5416_MAX_CHAINS];
  513. u8 rxTxMarginCh[AR5416_MAX_CHAINS];
  514. u8 adcDesiredSize;
  515. u8 pgaDesiredSize;
  516. u8 xlnaGainCh[AR5416_MAX_CHAINS];
  517. u8 txEndToXpaOff;
  518. u8 txEndToRxOn;
  519. u8 txFrameToXpaOn;
  520. u8 thresh62;
  521. u8 noiseFloorThreshCh[AR5416_MAX_CHAINS];
  522. u8 xpdGain;
  523. u8 xpd;
  524. u8 iqCalICh[AR5416_MAX_CHAINS];
  525. u8 iqCalQCh[AR5416_MAX_CHAINS];
  526. u8 pdGainOverlap;
  527. u8 ob;
  528. u8 db;
  529. u8 xpaBiasLvl;
  530. u8 pwrDecreaseFor2Chain;
  531. u8 pwrDecreaseFor3Chain;
  532. u8 txFrameToDataStart;
  533. u8 txFrameToPaOn;
  534. u8 ht40PowerIncForPdadc;
  535. u8 bswAtten[AR5416_MAX_CHAINS];
  536. u8 bswMargin[AR5416_MAX_CHAINS];
  537. u8 swSettleHt40;
  538. u8 xatten2Db[AR5416_MAX_CHAINS];
  539. u8 xatten2Margin[AR5416_MAX_CHAINS];
  540. u8 ob_ch1;
  541. u8 db_ch1;
  542. u8 useAnt1:1,
  543. force_xpaon:1,
  544. local_bias:1,
  545. femBandSelectUsed:1, xlnabufin:1, xlnaisel:2, xlnabufmode:1;
  546. u8 miscBits;
  547. u16 xpaBiasLvlFreq[3];
  548. u8 futureModal[6];
  549. struct spur_chan spurChans[AR5416_EEPROM_MODAL_SPURS];
  550. } __packed;
  551. struct modal_eep_4k_header {
  552. u32 antCtrlChain[AR5416_EEP4K_MAX_CHAINS];
  553. u32 antCtrlCommon;
  554. u8 antennaGainCh[AR5416_EEP4K_MAX_CHAINS];
  555. u8 switchSettling;
  556. u8 txRxAttenCh[AR5416_EEP4K_MAX_CHAINS];
  557. u8 rxTxMarginCh[AR5416_EEP4K_MAX_CHAINS];
  558. u8 adcDesiredSize;
  559. u8 pgaDesiredSize;
  560. u8 xlnaGainCh[AR5416_EEP4K_MAX_CHAINS];
  561. u8 txEndToXpaOff;
  562. u8 txEndToRxOn;
  563. u8 txFrameToXpaOn;
  564. u8 thresh62;
  565. u8 noiseFloorThreshCh[AR5416_EEP4K_MAX_CHAINS];
  566. u8 xpdGain;
  567. u8 xpd;
  568. u8 iqCalICh[AR5416_EEP4K_MAX_CHAINS];
  569. u8 iqCalQCh[AR5416_EEP4K_MAX_CHAINS];
  570. u8 pdGainOverlap;
  571. u8 ob_01;
  572. u8 db1_01;
  573. u8 xpaBiasLvl;
  574. u8 txFrameToDataStart;
  575. u8 txFrameToPaOn;
  576. u8 ht40PowerIncForPdadc;
  577. u8 bswAtten[AR5416_EEP4K_MAX_CHAINS];
  578. u8 bswMargin[AR5416_EEP4K_MAX_CHAINS];
  579. u8 swSettleHt40;
  580. u8 xatten2Db[AR5416_EEP4K_MAX_CHAINS];
  581. u8 xatten2Margin[AR5416_EEP4K_MAX_CHAINS];
  582. u8 db2_01;
  583. u8 version;
  584. u16 ob_234;
  585. u16 db1_234;
  586. u16 db2_234;
  587. u8 futureModal[4];
  588. struct spur_chan spurChans[AR5416_EEPROM_MODAL_SPURS];
  589. } __packed;
  590. struct cal_data_per_freq {
  591. u8 pwrPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
  592. u8 vpdPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
  593. } __packed;
  594. struct cal_data_per_freq_4k {
  595. u8 pwrPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_EEP4K_PD_GAIN_ICEPTS];
  596. u8 vpdPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_EEP4K_PD_GAIN_ICEPTS];
  597. } __packed;
  598. struct cal_target_power_leg {
  599. u8 bChannel;
  600. u8 tPow2x[4];
  601. } __packed;
  602. struct cal_target_power_ht {
  603. u8 bChannel;
  604. u8 tPow2x[8];
  605. } __packed;
  606. #ifdef __BIG_ENDIAN_BITFIELD
  607. struct cal_ctl_edges {
  608. u8 bChannel;
  609. u8 flag:2, tPower:6;
  610. } __packed;
  611. #else
  612. struct cal_ctl_edges {
  613. u8 bChannel;
  614. u8 tPower:6, flag:2;
  615. } __packed;
  616. #endif
  617. struct cal_ctl_data {
  618. struct cal_ctl_edges
  619. ctlEdges[AR5416_MAX_CHAINS][AR5416_NUM_BAND_EDGES];
  620. } __packed;
  621. struct cal_ctl_data_4k {
  622. struct cal_ctl_edges
  623. ctlEdges[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_BAND_EDGES];
  624. } __packed;
  625. struct ar5416_eeprom_def {
  626. struct base_eep_header baseEepHeader;
  627. u8 custData[64];
  628. struct modal_eep_header modalHeader[2];
  629. u8 calFreqPier5G[AR5416_NUM_5G_CAL_PIERS];
  630. u8 calFreqPier2G[AR5416_NUM_2G_CAL_PIERS];
  631. struct cal_data_per_freq
  632. calPierData5G[AR5416_MAX_CHAINS][AR5416_NUM_5G_CAL_PIERS];
  633. struct cal_data_per_freq
  634. calPierData2G[AR5416_MAX_CHAINS][AR5416_NUM_2G_CAL_PIERS];
  635. struct cal_target_power_leg
  636. calTargetPower5G[AR5416_NUM_5G_20_TARGET_POWERS];
  637. struct cal_target_power_ht
  638. calTargetPower5GHT20[AR5416_NUM_5G_20_TARGET_POWERS];
  639. struct cal_target_power_ht
  640. calTargetPower5GHT40[AR5416_NUM_5G_40_TARGET_POWERS];
  641. struct cal_target_power_leg
  642. calTargetPowerCck[AR5416_NUM_2G_CCK_TARGET_POWERS];
  643. struct cal_target_power_leg
  644. calTargetPower2G[AR5416_NUM_2G_20_TARGET_POWERS];
  645. struct cal_target_power_ht
  646. calTargetPower2GHT20[AR5416_NUM_2G_20_TARGET_POWERS];
  647. struct cal_target_power_ht
  648. calTargetPower2GHT40[AR5416_NUM_2G_40_TARGET_POWERS];
  649. u8 ctlIndex[AR5416_NUM_CTLS];
  650. struct cal_ctl_data ctlData[AR5416_NUM_CTLS];
  651. u8 padding;
  652. } __packed;
  653. struct ar5416_eeprom_4k {
  654. struct base_eep_header_4k baseEepHeader;
  655. u8 custData[20];
  656. struct modal_eep_4k_header modalHeader;
  657. u8 calFreqPier2G[AR5416_EEP4K_NUM_2G_CAL_PIERS];
  658. struct cal_data_per_freq_4k
  659. calPierData2G[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_2G_CAL_PIERS];
  660. struct cal_target_power_leg
  661. calTargetPowerCck[AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS];
  662. struct cal_target_power_leg
  663. calTargetPower2G[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS];
  664. struct cal_target_power_ht
  665. calTargetPower2GHT20[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS];
  666. struct cal_target_power_ht
  667. calTargetPower2GHT40[AR5416_EEP4K_NUM_2G_40_TARGET_POWERS];
  668. u8 ctlIndex[AR5416_EEP4K_NUM_CTLS];
  669. struct cal_ctl_data_4k ctlData[AR5416_EEP4K_NUM_CTLS];
  670. u8 padding;
  671. } __packed;
  672. struct ar5416IniArray {
  673. u32 *ia_array;
  674. u32 ia_rows;
  675. u32 ia_columns;
  676. };
  677. #define INIT_INI_ARRAY(iniarray, array, rows, columns) do { \
  678. (iniarray)->ia_array = (u32 *)(array); \
  679. (iniarray)->ia_rows = (rows); \
  680. (iniarray)->ia_columns = (columns); \
  681. } while (0)
  682. #define INI_RA(iniarray, row, column) \
  683. (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])
  684. #define INIT_CAL(_perCal) do { \
  685. (_perCal)->calState = CAL_WAITING; \
  686. (_perCal)->calNext = NULL; \
  687. } while (0)
  688. #define INSERT_CAL(_ahp, _perCal) \
  689. do { \
  690. if ((_ahp)->ah_cal_list_last == NULL) { \
  691. (_ahp)->ah_cal_list = \
  692. (_ahp)->ah_cal_list_last = (_perCal); \
  693. ((_ahp)->ah_cal_list_last)->calNext = (_perCal); \
  694. } else { \
  695. ((_ahp)->ah_cal_list_last)->calNext = (_perCal); \
  696. (_ahp)->ah_cal_list_last = (_perCal); \
  697. (_perCal)->calNext = (_ahp)->ah_cal_list; \
  698. } \
  699. } while (0)
  700. enum hal_cal_types {
  701. ADC_DC_INIT_CAL = 0x1,
  702. ADC_GAIN_CAL = 0x2,
  703. ADC_DC_CAL = 0x4,
  704. IQ_MISMATCH_CAL = 0x8
  705. };
  706. enum hal_cal_state {
  707. CAL_INACTIVE,
  708. CAL_WAITING,
  709. CAL_RUNNING,
  710. CAL_DONE
  711. };
  712. #define MIN_CAL_SAMPLES 1
  713. #define MAX_CAL_SAMPLES 64
  714. #define INIT_LOG_COUNT 5
  715. #define PER_MIN_LOG_COUNT 2
  716. #define PER_MAX_LOG_COUNT 10
  717. struct hal_percal_data {
  718. enum hal_cal_types calType;
  719. u32 calNumSamples;
  720. u32 calCountMax;
  721. void (*calCollect) (struct ath_hal *);
  722. void (*calPostProc) (struct ath_hal *, u8);
  723. };
  724. struct hal_cal_list {
  725. const struct hal_percal_data *calData;
  726. enum hal_cal_state calState;
  727. struct hal_cal_list *calNext;
  728. };
  729. /*
  730. * Enum to indentify the eeprom mappings
  731. */
  732. enum hal_eep_map {
  733. EEP_MAP_DEFAULT = 0x0,
  734. EEP_MAP_4KBITS,
  735. EEP_MAP_MAX
  736. };
  737. struct ath_hal_5416 {
  738. struct ath_hal ah;
  739. union {
  740. struct ar5416_eeprom_def def;
  741. struct ar5416_eeprom_4k map4k;
  742. } ah_eeprom;
  743. struct ar5416Stats ah_stats;
  744. struct ath9k_tx_queue_info ah_txq[ATH9K_NUM_TX_QUEUES];
  745. void __iomem *ah_cal_mem;
  746. u8 ah_macaddr[ETH_ALEN];
  747. u8 ah_bssid[ETH_ALEN];
  748. u8 ah_bssidmask[ETH_ALEN];
  749. u16 ah_assocId;
  750. int16_t ah_curchanRadIndex;
  751. u32 ah_maskReg;
  752. u32 ah_txOkInterruptMask;
  753. u32 ah_txErrInterruptMask;
  754. u32 ah_txDescInterruptMask;
  755. u32 ah_txEolInterruptMask;
  756. u32 ah_txUrnInterruptMask;
  757. bool ah_chipFullSleep;
  758. u32 ah_atimWindow;
  759. u16 ah_antennaSwitchSwap;
  760. enum ath9k_ant_setting ah_diversityControl;
  761. /* Calibration */
  762. enum hal_cal_types ah_suppCals;
  763. struct hal_cal_list ah_iqCalData;
  764. struct hal_cal_list ah_adcGainCalData;
  765. struct hal_cal_list ah_adcDcCalInitData;
  766. struct hal_cal_list ah_adcDcCalData;
  767. struct hal_cal_list *ah_cal_list;
  768. struct hal_cal_list *ah_cal_list_last;
  769. struct hal_cal_list *ah_cal_list_curr;
  770. #define ah_totalPowerMeasI ah_Meas0.unsign
  771. #define ah_totalPowerMeasQ ah_Meas1.unsign
  772. #define ah_totalIqCorrMeas ah_Meas2.sign
  773. #define ah_totalAdcIOddPhase ah_Meas0.unsign
  774. #define ah_totalAdcIEvenPhase ah_Meas1.unsign
  775. #define ah_totalAdcQOddPhase ah_Meas2.unsign
  776. #define ah_totalAdcQEvenPhase ah_Meas3.unsign
  777. #define ah_totalAdcDcOffsetIOddPhase ah_Meas0.sign
  778. #define ah_totalAdcDcOffsetIEvenPhase ah_Meas1.sign
  779. #define ah_totalAdcDcOffsetQOddPhase ah_Meas2.sign
  780. #define ah_totalAdcDcOffsetQEvenPhase ah_Meas3.sign
  781. union {
  782. u32 unsign[AR5416_MAX_CHAINS];
  783. int32_t sign[AR5416_MAX_CHAINS];
  784. } ah_Meas0;
  785. union {
  786. u32 unsign[AR5416_MAX_CHAINS];
  787. int32_t sign[AR5416_MAX_CHAINS];
  788. } ah_Meas1;
  789. union {
  790. u32 unsign[AR5416_MAX_CHAINS];
  791. int32_t sign[AR5416_MAX_CHAINS];
  792. } ah_Meas2;
  793. union {
  794. u32 unsign[AR5416_MAX_CHAINS];
  795. int32_t sign[AR5416_MAX_CHAINS];
  796. } ah_Meas3;
  797. u16 ah_CalSamples;
  798. u32 ah_staId1Defaults;
  799. u32 ah_miscMode;
  800. enum {
  801. AUTO_32KHZ,
  802. USE_32KHZ,
  803. DONT_USE_32KHZ,
  804. } ah_enable32kHzClock;
  805. /* RF */
  806. u32 *ah_analogBank0Data;
  807. u32 *ah_analogBank1Data;
  808. u32 *ah_analogBank2Data;
  809. u32 *ah_analogBank3Data;
  810. u32 *ah_analogBank6Data;
  811. u32 *ah_analogBank6TPCData;
  812. u32 *ah_analogBank7Data;
  813. u32 *ah_addac5416_21;
  814. u32 *ah_bank6Temp;
  815. int16_t ah_txPowerIndexOffset;
  816. u32 ah_beaconInterval;
  817. u32 ah_slottime;
  818. u32 ah_acktimeout;
  819. u32 ah_ctstimeout;
  820. u32 ah_globaltxtimeout;
  821. u8 ah_gBeaconRate;
  822. u32 ah_gpioSelect;
  823. u32 ah_polarity;
  824. u32 ah_gpioBit;
  825. /* ANI */
  826. u32 ah_procPhyErr;
  827. bool ah_hasHwPhyCounters;
  828. u32 ah_aniPeriod;
  829. struct ar5416AniState *ah_curani;
  830. struct ar5416AniState ah_ani[255];
  831. int ah_totalSizeDesired[5];
  832. int ah_coarseHigh[5];
  833. int ah_coarseLow[5];
  834. int ah_firpwr[5];
  835. enum ath9k_ani_cmd ah_ani_function;
  836. u32 ah_intrTxqs;
  837. bool ah_intrMitigation;
  838. enum ath9k_ht_extprotspacing ah_extprotspacing;
  839. u8 ah_txchainmask;
  840. u8 ah_rxchainmask;
  841. struct ar5416IniArray ah_iniModes;
  842. struct ar5416IniArray ah_iniCommon;
  843. struct ar5416IniArray ah_iniBank0;
  844. struct ar5416IniArray ah_iniBB_RfGain;
  845. struct ar5416IniArray ah_iniBank1;
  846. struct ar5416IniArray ah_iniBank2;
  847. struct ar5416IniArray ah_iniBank3;
  848. struct ar5416IniArray ah_iniBank6;
  849. struct ar5416IniArray ah_iniBank6TPC;
  850. struct ar5416IniArray ah_iniBank7;
  851. struct ar5416IniArray ah_iniAddac;
  852. struct ar5416IniArray ah_iniPcieSerdes;
  853. struct ar5416IniArray ah_iniModesAdditional;
  854. struct ar5416IniArray ah_iniModesRxGain;
  855. struct ar5416IniArray ah_iniModesTxGain;
  856. /* To indicate EEPROM mapping used */
  857. enum hal_eep_map ah_eep_map;
  858. };
  859. #define AH5416(_ah) ((struct ath_hal_5416 *)(_ah))
  860. #define FREQ2FBIN(x, y) ((y) ? ((x) - 2300) : (((x) - 4800) / 5))
  861. #define ar5416RfDetach(ah) do { \
  862. if (AH5416(ah)->ah_rfHal.rfDetach != NULL) \
  863. AH5416(ah)->ah_rfHal.rfDetach(ah); \
  864. } while (0)
  865. #define ath9k_hw_use_flash(_ah) \
  866. (!(_ah->ah_flags & AH_USE_EEPROM))
  867. #define DO_DELAY(x) do { \
  868. if ((++(x) % 64) == 0) \
  869. udelay(1); \
  870. } while (0)
  871. #define REG_WRITE_ARRAY(iniarray, column, regWr) do { \
  872. int r; \
  873. for (r = 0; r < ((iniarray)->ia_rows); r++) { \
  874. REG_WRITE(ah, INI_RA((iniarray), (r), 0), \
  875. INI_RA((iniarray), r, (column))); \
  876. DO_DELAY(regWr); \
  877. } \
  878. } while (0)
  879. #define BASE_ACTIVATE_DELAY 100
  880. #define RTC_PLL_SETTLE_DELAY 1000
  881. #define COEF_SCALE_S 24
  882. #define HT40_CHANNEL_CENTER_SHIFT 10
  883. #define AR5416_EEPROM_MAGIC_OFFSET 0x0
  884. #define AR5416_EEPROM_S 2
  885. #define AR5416_EEPROM_OFFSET 0x2000
  886. #define AR5416_EEPROM_START_ADDR \
  887. (AR_SREV_9100(ah)) ? 0x1fff1000 : 0x503f1200
  888. #define AR5416_EEPROM_MAX 0xae0
  889. #define ar5416_get_eep_ver(_ahp) \
  890. (((_ahp)->ah_eeprom.def.baseEepHeader.version >> 12) & 0xF)
  891. #define ar5416_get_eep_rev(_ahp) \
  892. (((_ahp)->ah_eeprom.def.baseEepHeader.version) & 0xFFF)
  893. #define ar5416_get_ntxchains(_txchainmask) \
  894. (((_txchainmask >> 2) & 1) + \
  895. ((_txchainmask >> 1) & 1) + (_txchainmask & 1))
  896. /* EEPROM 4K bit map definations */
  897. #define ar5416_get_eep4k_ver(_ahp) \
  898. (((_ahp)->ah_eeprom.map4k.baseEepHeader.version >> 12) & 0xF)
  899. #define ar5416_get_eep4k_rev(_ahp) \
  900. (((_ahp)->ah_eeprom.map4k.baseEepHeader.version) & 0xFFF)
  901. #ifdef __BIG_ENDIAN
  902. #define AR5416_EEPROM_MAGIC 0x5aa5
  903. #else
  904. #define AR5416_EEPROM_MAGIC 0xa55a
  905. #endif
  906. #define ATH9K_POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
  907. #define ATH9K_ANTENNA0_CHAINMASK 0x1
  908. #define ATH9K_ANTENNA1_CHAINMASK 0x2
  909. #define ATH9K_NUM_DMA_DEBUG_REGS 8
  910. #define ATH9K_NUM_QUEUES 10
  911. #define HAL_NOISE_IMMUNE_MAX 4
  912. #define HAL_SPUR_IMMUNE_MAX 7
  913. #define HAL_FIRST_STEP_MAX 2
  914. #define ATH9K_ANI_OFDM_TRIG_HIGH 500
  915. #define ATH9K_ANI_OFDM_TRIG_LOW 200
  916. #define ATH9K_ANI_CCK_TRIG_HIGH 200
  917. #define ATH9K_ANI_CCK_TRIG_LOW 100
  918. #define ATH9K_ANI_NOISE_IMMUNE_LVL 4
  919. #define ATH9K_ANI_USE_OFDM_WEAK_SIG true
  920. #define ATH9K_ANI_CCK_WEAK_SIG_THR false
  921. #define ATH9K_ANI_SPUR_IMMUNE_LVL 7
  922. #define ATH9K_ANI_FIRSTEP_LVL 0
  923. #define ATH9K_ANI_RSSI_THR_HIGH 40
  924. #define ATH9K_ANI_RSSI_THR_LOW 7
  925. #define ATH9K_ANI_PERIOD 100
  926. #define AR_GPIOD_MASK 0x00001FFF
  927. #define AR_GPIO_BIT(_gpio) (1 << (_gpio))
  928. #define HAL_EP_RND(x, mul) \
  929. ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
  930. #define BEACON_RSSI(ahp) \
  931. HAL_EP_RND(ahp->ah_stats.ast_nodestats.ns_avgbrssi, \
  932. ATH9K_RSSI_EP_MULTIPLIER)
  933. #define ah_mibStats ah_stats.ast_mibstats
  934. #define AH_TIMEOUT 100000
  935. #define AH_TIME_QUANTUM 10
  936. #define AR_KEYTABLE_SIZE 128
  937. #define POWER_UP_TIME 200000
  938. #define EXT_ADDITIVE (0x8000)
  939. #define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
  940. #define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
  941. #define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
  942. #define SUB_NUM_CTL_MODES_AT_5G_40 2
  943. #define SUB_NUM_CTL_MODES_AT_2G_40 3
  944. #define SPUR_RSSI_THRESH 40
  945. #define TU_TO_USEC(_tu) ((_tu) << 10)
  946. #define CAB_TIMEOUT_VAL 10
  947. #define BEACON_TIMEOUT_VAL 10
  948. #define MIN_BEACON_TIMEOUT_VAL 1
  949. #define SLEEP_SLOP 3
  950. #define CCK_SIFS_TIME 10
  951. #define CCK_PREAMBLE_BITS 144
  952. #define CCK_PLCP_BITS 48
  953. #define OFDM_SIFS_TIME 16
  954. #define OFDM_PREAMBLE_TIME 20
  955. #define OFDM_PLCP_BITS 22
  956. #define OFDM_SYMBOL_TIME 4
  957. #define OFDM_SIFS_TIME_HALF 32
  958. #define OFDM_PREAMBLE_TIME_HALF 40
  959. #define OFDM_PLCP_BITS_HALF 22
  960. #define OFDM_SYMBOL_TIME_HALF 8
  961. #define OFDM_SIFS_TIME_QUARTER 64
  962. #define OFDM_PREAMBLE_TIME_QUARTER 80
  963. #define OFDM_PLCP_BITS_QUARTER 22
  964. #define OFDM_SYMBOL_TIME_QUARTER 16
  965. u32 ath9k_hw_get_eeprom(struct ath_hal *ah,
  966. enum eeprom_param param);
  967. #endif