hw.h 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088
  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_NUM_5G_CAL_PIERS 8
  384. #define AR5416_NUM_2G_CAL_PIERS 4
  385. #define AR5416_NUM_5G_20_TARGET_POWERS 8
  386. #define AR5416_NUM_5G_40_TARGET_POWERS 8
  387. #define AR5416_NUM_2G_CCK_TARGET_POWERS 3
  388. #define AR5416_NUM_2G_20_TARGET_POWERS 4
  389. #define AR5416_NUM_2G_40_TARGET_POWERS 4
  390. #define AR5416_NUM_CTLS 24
  391. #define AR5416_NUM_BAND_EDGES 8
  392. #define AR5416_NUM_PD_GAINS 4
  393. #define AR5416_PD_GAINS_IN_MASK 4
  394. #define AR5416_PD_GAIN_ICEPTS 5
  395. #define AR5416_EEPROM_MODAL_SPURS 5
  396. #define AR5416_MAX_RATE_POWER 63
  397. #define AR5416_NUM_PDADC_VALUES 128
  398. #define AR5416_BCHAN_UNUSED 0xFF
  399. #define AR5416_MAX_PWR_RANGE_IN_HALF_DB 64
  400. #define AR5416_MAX_CHAINS 3
  401. #define AR5416_PWR_TABLE_OFFSET -5
  402. /* Rx gain type values */
  403. #define AR5416_EEP_RXGAIN_23DB_BACKOFF 0
  404. #define AR5416_EEP_RXGAIN_13DB_BACKOFF 1
  405. #define AR5416_EEP_RXGAIN_ORIG 2
  406. /* Tx gain type values */
  407. #define AR5416_EEP_TXGAIN_ORIGINAL 0
  408. #define AR5416_EEP_TXGAIN_HIGH_POWER 1
  409. #define AR5416_EEP4K_START_LOC 64
  410. #define AR5416_EEP4K_NUM_2G_CAL_PIERS 3
  411. #define AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS 3
  412. #define AR5416_EEP4K_NUM_2G_20_TARGET_POWERS 3
  413. #define AR5416_EEP4K_NUM_2G_40_TARGET_POWERS 3
  414. #define AR5416_EEP4K_NUM_CTLS 12
  415. #define AR5416_EEP4K_NUM_BAND_EDGES 4
  416. #define AR5416_EEP4K_NUM_PD_GAINS 2
  417. #define AR5416_EEP4K_PD_GAINS_IN_MASK 4
  418. #define AR5416_EEP4K_PD_GAIN_ICEPTS 5
  419. #define AR5416_EEP4K_MAX_CHAINS 1
  420. enum eeprom_param {
  421. EEP_NFTHRESH_5,
  422. EEP_NFTHRESH_2,
  423. EEP_MAC_MSW,
  424. EEP_MAC_MID,
  425. EEP_MAC_LSW,
  426. EEP_REG_0,
  427. EEP_REG_1,
  428. EEP_OP_CAP,
  429. EEP_OP_MODE,
  430. EEP_RF_SILENT,
  431. EEP_OB_5,
  432. EEP_DB_5,
  433. EEP_OB_2,
  434. EEP_DB_2,
  435. EEP_MINOR_REV,
  436. EEP_TX_MASK,
  437. EEP_RX_MASK,
  438. EEP_RXGAIN_TYPE,
  439. EEP_TXGAIN_TYPE,
  440. };
  441. enum ar5416_rates {
  442. rate6mb, rate9mb, rate12mb, rate18mb,
  443. rate24mb, rate36mb, rate48mb, rate54mb,
  444. rate1l, rate2l, rate2s, rate5_5l,
  445. rate5_5s, rate11l, rate11s, rateXr,
  446. rateHt20_0, rateHt20_1, rateHt20_2, rateHt20_3,
  447. rateHt20_4, rateHt20_5, rateHt20_6, rateHt20_7,
  448. rateHt40_0, rateHt40_1, rateHt40_2, rateHt40_3,
  449. rateHt40_4, rateHt40_5, rateHt40_6, rateHt40_7,
  450. rateDupCck, rateDupOfdm, rateExtCck, rateExtOfdm,
  451. Ar5416RateSize
  452. };
  453. enum ath9k_hal_freq_band {
  454. ATH9K_HAL_FREQ_BAND_5GHZ = 0,
  455. ATH9K_HAL_FREQ_BAND_2GHZ = 1
  456. };
  457. struct base_eep_header {
  458. u16 length;
  459. u16 checksum;
  460. u16 version;
  461. u8 opCapFlags;
  462. u8 eepMisc;
  463. u16 regDmn[2];
  464. u8 macAddr[6];
  465. u8 rxMask;
  466. u8 txMask;
  467. u16 rfSilent;
  468. u16 blueToothOptions;
  469. u16 deviceCap;
  470. u32 binBuildNumber;
  471. u8 deviceType;
  472. u8 pwdclkind;
  473. u8 futureBase_1[2];
  474. u8 rxGainType;
  475. u8 futureBase_2[3];
  476. u8 txGainType;
  477. u8 futureBase_3[25];
  478. } __packed;
  479. struct base_eep_header_4k {
  480. u16 length;
  481. u16 checksum;
  482. u16 version;
  483. u8 opCapFlags;
  484. u8 eepMisc;
  485. u16 regDmn[2];
  486. u8 macAddr[6];
  487. u8 rxMask;
  488. u8 txMask;
  489. u16 rfSilent;
  490. u16 blueToothOptions;
  491. u16 deviceCap;
  492. u32 binBuildNumber;
  493. u8 deviceType;
  494. u8 futureBase[1];
  495. } __packed;
  496. struct spur_chan {
  497. u16 spurChan;
  498. u8 spurRangeLow;
  499. u8 spurRangeHigh;
  500. } __packed;
  501. struct modal_eep_header {
  502. u32 antCtrlChain[AR5416_MAX_CHAINS];
  503. u32 antCtrlCommon;
  504. u8 antennaGainCh[AR5416_MAX_CHAINS];
  505. u8 switchSettling;
  506. u8 txRxAttenCh[AR5416_MAX_CHAINS];
  507. u8 rxTxMarginCh[AR5416_MAX_CHAINS];
  508. u8 adcDesiredSize;
  509. u8 pgaDesiredSize;
  510. u8 xlnaGainCh[AR5416_MAX_CHAINS];
  511. u8 txEndToXpaOff;
  512. u8 txEndToRxOn;
  513. u8 txFrameToXpaOn;
  514. u8 thresh62;
  515. u8 noiseFloorThreshCh[AR5416_MAX_CHAINS];
  516. u8 xpdGain;
  517. u8 xpd;
  518. u8 iqCalICh[AR5416_MAX_CHAINS];
  519. u8 iqCalQCh[AR5416_MAX_CHAINS];
  520. u8 pdGainOverlap;
  521. u8 ob;
  522. u8 db;
  523. u8 xpaBiasLvl;
  524. u8 pwrDecreaseFor2Chain;
  525. u8 pwrDecreaseFor3Chain;
  526. u8 txFrameToDataStart;
  527. u8 txFrameToPaOn;
  528. u8 ht40PowerIncForPdadc;
  529. u8 bswAtten[AR5416_MAX_CHAINS];
  530. u8 bswMargin[AR5416_MAX_CHAINS];
  531. u8 swSettleHt40;
  532. u8 xatten2Db[AR5416_MAX_CHAINS];
  533. u8 xatten2Margin[AR5416_MAX_CHAINS];
  534. u8 ob_ch1;
  535. u8 db_ch1;
  536. u8 useAnt1:1,
  537. force_xpaon:1,
  538. local_bias:1,
  539. femBandSelectUsed:1, xlnabufin:1, xlnaisel:2, xlnabufmode:1;
  540. u8 futureModalar9280;
  541. u16 xpaBiasLvlFreq[3];
  542. u8 futureModal[6];
  543. struct spur_chan spurChans[AR5416_EEPROM_MODAL_SPURS];
  544. } __packed;
  545. struct modal_eep_4k_header {
  546. u32 antCtrlChain[AR5416_EEP4K_MAX_CHAINS];
  547. u32 antCtrlCommon;
  548. u8 antennaGainCh[AR5416_EEP4K_MAX_CHAINS];
  549. u8 switchSettling;
  550. u8 txRxAttenCh[AR5416_EEP4K_MAX_CHAINS];
  551. u8 rxTxMarginCh[AR5416_EEP4K_MAX_CHAINS];
  552. u8 adcDesiredSize;
  553. u8 pgaDesiredSize;
  554. u8 xlnaGainCh[AR5416_EEP4K_MAX_CHAINS];
  555. u8 txEndToXpaOff;
  556. u8 txEndToRxOn;
  557. u8 txFrameToXpaOn;
  558. u8 thresh62;
  559. u8 noiseFloorThreshCh[AR5416_EEP4K_MAX_CHAINS];
  560. u8 xpdGain;
  561. u8 xpd;
  562. u8 iqCalICh[AR5416_EEP4K_MAX_CHAINS];
  563. u8 iqCalQCh[AR5416_EEP4K_MAX_CHAINS];
  564. u8 pdGainOverlap;
  565. u8 ob_01;
  566. u8 db1_01;
  567. u8 xpaBiasLvl;
  568. u8 txFrameToDataStart;
  569. u8 txFrameToPaOn;
  570. u8 ht40PowerIncForPdadc;
  571. u8 bswAtten[AR5416_EEP4K_MAX_CHAINS];
  572. u8 bswMargin[AR5416_EEP4K_MAX_CHAINS];
  573. u8 swSettleHt40;
  574. u8 xatten2Db[AR5416_EEP4K_MAX_CHAINS];
  575. u8 xatten2Margin[AR5416_EEP4K_MAX_CHAINS];
  576. u8 db2_01;
  577. u8 version;
  578. u16 ob_234;
  579. u16 db1_234;
  580. u16 db2_234;
  581. u8 futureModal[4];
  582. struct spur_chan spurChans[AR5416_EEPROM_MODAL_SPURS];
  583. } __packed;
  584. struct cal_data_per_freq {
  585. u8 pwrPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
  586. u8 vpdPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
  587. } __packed;
  588. struct cal_data_per_freq_4k {
  589. u8 pwrPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_EEP4K_PD_GAIN_ICEPTS];
  590. u8 vpdPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_EEP4K_PD_GAIN_ICEPTS];
  591. } __packed;
  592. struct cal_target_power_leg {
  593. u8 bChannel;
  594. u8 tPow2x[4];
  595. } __packed;
  596. struct cal_target_power_ht {
  597. u8 bChannel;
  598. u8 tPow2x[8];
  599. } __packed;
  600. #ifdef __BIG_ENDIAN_BITFIELD
  601. struct cal_ctl_edges {
  602. u8 bChannel;
  603. u8 flag:2, tPower:6;
  604. } __packed;
  605. #else
  606. struct cal_ctl_edges {
  607. u8 bChannel;
  608. u8 tPower:6, flag:2;
  609. } __packed;
  610. #endif
  611. struct cal_ctl_data {
  612. struct cal_ctl_edges
  613. ctlEdges[AR5416_MAX_CHAINS][AR5416_NUM_BAND_EDGES];
  614. } __packed;
  615. struct cal_ctl_data_4k {
  616. struct cal_ctl_edges
  617. ctlEdges[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_BAND_EDGES];
  618. } __packed;
  619. struct ar5416_eeprom_def {
  620. struct base_eep_header baseEepHeader;
  621. u8 custData[64];
  622. struct modal_eep_header modalHeader[2];
  623. u8 calFreqPier5G[AR5416_NUM_5G_CAL_PIERS];
  624. u8 calFreqPier2G[AR5416_NUM_2G_CAL_PIERS];
  625. struct cal_data_per_freq
  626. calPierData5G[AR5416_MAX_CHAINS][AR5416_NUM_5G_CAL_PIERS];
  627. struct cal_data_per_freq
  628. calPierData2G[AR5416_MAX_CHAINS][AR5416_NUM_2G_CAL_PIERS];
  629. struct cal_target_power_leg
  630. calTargetPower5G[AR5416_NUM_5G_20_TARGET_POWERS];
  631. struct cal_target_power_ht
  632. calTargetPower5GHT20[AR5416_NUM_5G_20_TARGET_POWERS];
  633. struct cal_target_power_ht
  634. calTargetPower5GHT40[AR5416_NUM_5G_40_TARGET_POWERS];
  635. struct cal_target_power_leg
  636. calTargetPowerCck[AR5416_NUM_2G_CCK_TARGET_POWERS];
  637. struct cal_target_power_leg
  638. calTargetPower2G[AR5416_NUM_2G_20_TARGET_POWERS];
  639. struct cal_target_power_ht
  640. calTargetPower2GHT20[AR5416_NUM_2G_20_TARGET_POWERS];
  641. struct cal_target_power_ht
  642. calTargetPower2GHT40[AR5416_NUM_2G_40_TARGET_POWERS];
  643. u8 ctlIndex[AR5416_NUM_CTLS];
  644. struct cal_ctl_data ctlData[AR5416_NUM_CTLS];
  645. u8 padding;
  646. } __packed;
  647. struct ar5416_eeprom_4k {
  648. struct base_eep_header_4k baseEepHeader;
  649. u8 custData[20];
  650. struct modal_eep_4k_header modalHeader;
  651. u8 calFreqPier2G[AR5416_EEP4K_NUM_2G_CAL_PIERS];
  652. struct cal_data_per_freq_4k
  653. calPierData2G[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_2G_CAL_PIERS];
  654. struct cal_target_power_leg
  655. calTargetPowerCck[AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS];
  656. struct cal_target_power_leg
  657. calTargetPower2G[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS];
  658. struct cal_target_power_ht
  659. calTargetPower2GHT20[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS];
  660. struct cal_target_power_ht
  661. calTargetPower2GHT40[AR5416_EEP4K_NUM_2G_40_TARGET_POWERS];
  662. u8 ctlIndex[AR5416_EEP4K_NUM_CTLS];
  663. struct cal_ctl_data_4k ctlData[AR5416_EEP4K_NUM_CTLS];
  664. u8 padding;
  665. } __packed;
  666. struct ar5416IniArray {
  667. u32 *ia_array;
  668. u32 ia_rows;
  669. u32 ia_columns;
  670. };
  671. #define INIT_INI_ARRAY(iniarray, array, rows, columns) do { \
  672. (iniarray)->ia_array = (u32 *)(array); \
  673. (iniarray)->ia_rows = (rows); \
  674. (iniarray)->ia_columns = (columns); \
  675. } while (0)
  676. #define INI_RA(iniarray, row, column) \
  677. (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])
  678. #define INIT_CAL(_perCal) do { \
  679. (_perCal)->calState = CAL_WAITING; \
  680. (_perCal)->calNext = NULL; \
  681. } while (0)
  682. #define INSERT_CAL(_ahp, _perCal) \
  683. do { \
  684. if ((_ahp)->ah_cal_list_last == NULL) { \
  685. (_ahp)->ah_cal_list = \
  686. (_ahp)->ah_cal_list_last = (_perCal); \
  687. ((_ahp)->ah_cal_list_last)->calNext = (_perCal); \
  688. } else { \
  689. ((_ahp)->ah_cal_list_last)->calNext = (_perCal); \
  690. (_ahp)->ah_cal_list_last = (_perCal); \
  691. (_perCal)->calNext = (_ahp)->ah_cal_list; \
  692. } \
  693. } while (0)
  694. enum hal_cal_types {
  695. ADC_DC_INIT_CAL = 0x1,
  696. ADC_GAIN_CAL = 0x2,
  697. ADC_DC_CAL = 0x4,
  698. IQ_MISMATCH_CAL = 0x8
  699. };
  700. enum hal_cal_state {
  701. CAL_INACTIVE,
  702. CAL_WAITING,
  703. CAL_RUNNING,
  704. CAL_DONE
  705. };
  706. #define MIN_CAL_SAMPLES 1
  707. #define MAX_CAL_SAMPLES 64
  708. #define INIT_LOG_COUNT 5
  709. #define PER_MIN_LOG_COUNT 2
  710. #define PER_MAX_LOG_COUNT 10
  711. struct hal_percal_data {
  712. enum hal_cal_types calType;
  713. u32 calNumSamples;
  714. u32 calCountMax;
  715. void (*calCollect) (struct ath_hal *);
  716. void (*calPostProc) (struct ath_hal *, u8);
  717. };
  718. struct hal_cal_list {
  719. const struct hal_percal_data *calData;
  720. enum hal_cal_state calState;
  721. struct hal_cal_list *calNext;
  722. };
  723. /*
  724. * Enum to indentify the eeprom mappings
  725. */
  726. enum hal_eep_map {
  727. EEP_MAP_DEFAULT = 0x0,
  728. EEP_MAP_4KBITS,
  729. EEP_MAP_MAX
  730. };
  731. struct ath_hal_5416 {
  732. struct ath_hal ah;
  733. union {
  734. struct ar5416_eeprom_def def;
  735. struct ar5416_eeprom_4k map4k;
  736. } ah_eeprom;
  737. struct ar5416Stats ah_stats;
  738. struct ath9k_tx_queue_info ah_txq[ATH9K_NUM_TX_QUEUES];
  739. void __iomem *ah_cal_mem;
  740. u8 ah_macaddr[ETH_ALEN];
  741. u8 ah_bssid[ETH_ALEN];
  742. u8 ah_bssidmask[ETH_ALEN];
  743. u16 ah_assocId;
  744. int16_t ah_curchanRadIndex;
  745. u32 ah_maskReg;
  746. u32 ah_txOkInterruptMask;
  747. u32 ah_txErrInterruptMask;
  748. u32 ah_txDescInterruptMask;
  749. u32 ah_txEolInterruptMask;
  750. u32 ah_txUrnInterruptMask;
  751. bool ah_chipFullSleep;
  752. u32 ah_atimWindow;
  753. u16 ah_antennaSwitchSwap;
  754. enum ath9k_power_mode ah_powerMode;
  755. enum ath9k_ant_setting ah_diversityControl;
  756. /* Calibration */
  757. enum hal_cal_types ah_suppCals;
  758. struct hal_cal_list ah_iqCalData;
  759. struct hal_cal_list ah_adcGainCalData;
  760. struct hal_cal_list ah_adcDcCalInitData;
  761. struct hal_cal_list ah_adcDcCalData;
  762. struct hal_cal_list *ah_cal_list;
  763. struct hal_cal_list *ah_cal_list_last;
  764. struct hal_cal_list *ah_cal_list_curr;
  765. #define ah_totalPowerMeasI ah_Meas0.unsign
  766. #define ah_totalPowerMeasQ ah_Meas1.unsign
  767. #define ah_totalIqCorrMeas ah_Meas2.sign
  768. #define ah_totalAdcIOddPhase ah_Meas0.unsign
  769. #define ah_totalAdcIEvenPhase ah_Meas1.unsign
  770. #define ah_totalAdcQOddPhase ah_Meas2.unsign
  771. #define ah_totalAdcQEvenPhase ah_Meas3.unsign
  772. #define ah_totalAdcDcOffsetIOddPhase ah_Meas0.sign
  773. #define ah_totalAdcDcOffsetIEvenPhase ah_Meas1.sign
  774. #define ah_totalAdcDcOffsetQOddPhase ah_Meas2.sign
  775. #define ah_totalAdcDcOffsetQEvenPhase ah_Meas3.sign
  776. union {
  777. u32 unsign[AR5416_MAX_CHAINS];
  778. int32_t sign[AR5416_MAX_CHAINS];
  779. } ah_Meas0;
  780. union {
  781. u32 unsign[AR5416_MAX_CHAINS];
  782. int32_t sign[AR5416_MAX_CHAINS];
  783. } ah_Meas1;
  784. union {
  785. u32 unsign[AR5416_MAX_CHAINS];
  786. int32_t sign[AR5416_MAX_CHAINS];
  787. } ah_Meas2;
  788. union {
  789. u32 unsign[AR5416_MAX_CHAINS];
  790. int32_t sign[AR5416_MAX_CHAINS];
  791. } ah_Meas3;
  792. u16 ah_CalSamples;
  793. u32 ah_staId1Defaults;
  794. u32 ah_miscMode;
  795. enum {
  796. AUTO_32KHZ,
  797. USE_32KHZ,
  798. DONT_USE_32KHZ,
  799. } ah_enable32kHzClock;
  800. /* RF */
  801. u32 *ah_analogBank0Data;
  802. u32 *ah_analogBank1Data;
  803. u32 *ah_analogBank2Data;
  804. u32 *ah_analogBank3Data;
  805. u32 *ah_analogBank6Data;
  806. u32 *ah_analogBank6TPCData;
  807. u32 *ah_analogBank7Data;
  808. u32 *ah_addac5416_21;
  809. u32 *ah_bank6Temp;
  810. int16_t ah_txPowerIndexOffset;
  811. u32 ah_beaconInterval;
  812. u32 ah_slottime;
  813. u32 ah_acktimeout;
  814. u32 ah_ctstimeout;
  815. u32 ah_globaltxtimeout;
  816. u8 ah_gBeaconRate;
  817. u32 ah_gpioSelect;
  818. u32 ah_polarity;
  819. u32 ah_gpioBit;
  820. /* ANI */
  821. u32 ah_procPhyErr;
  822. bool ah_hasHwPhyCounters;
  823. u32 ah_aniPeriod;
  824. struct ar5416AniState *ah_curani;
  825. struct ar5416AniState ah_ani[255];
  826. int ah_totalSizeDesired[5];
  827. int ah_coarseHigh[5];
  828. int ah_coarseLow[5];
  829. int ah_firpwr[5];
  830. enum ath9k_ani_cmd ah_ani_function;
  831. u32 ah_intrTxqs;
  832. bool ah_intrMitigation;
  833. enum ath9k_ht_extprotspacing ah_extprotspacing;
  834. u8 ah_txchainmask;
  835. u8 ah_rxchainmask;
  836. struct ar5416IniArray ah_iniModes;
  837. struct ar5416IniArray ah_iniCommon;
  838. struct ar5416IniArray ah_iniBank0;
  839. struct ar5416IniArray ah_iniBB_RfGain;
  840. struct ar5416IniArray ah_iniBank1;
  841. struct ar5416IniArray ah_iniBank2;
  842. struct ar5416IniArray ah_iniBank3;
  843. struct ar5416IniArray ah_iniBank6;
  844. struct ar5416IniArray ah_iniBank6TPC;
  845. struct ar5416IniArray ah_iniBank7;
  846. struct ar5416IniArray ah_iniAddac;
  847. struct ar5416IniArray ah_iniPcieSerdes;
  848. struct ar5416IniArray ah_iniModesAdditional;
  849. struct ar5416IniArray ah_iniModesRxGain;
  850. struct ar5416IniArray ah_iniModesTxGain;
  851. /* To indicate EEPROM mapping used */
  852. enum hal_eep_map ah_eep_map;
  853. };
  854. #define AH5416(_ah) ((struct ath_hal_5416 *)(_ah))
  855. #define FREQ2FBIN(x, y) ((y) ? ((x) - 2300) : (((x) - 4800) / 5))
  856. #define ar5416RfDetach(ah) do { \
  857. if (AH5416(ah)->ah_rfHal.rfDetach != NULL) \
  858. AH5416(ah)->ah_rfHal.rfDetach(ah); \
  859. } while (0)
  860. #define ath9k_hw_use_flash(_ah) \
  861. (!(_ah->ah_flags & AH_USE_EEPROM))
  862. #define DO_DELAY(x) do { \
  863. if ((++(x) % 64) == 0) \
  864. udelay(1); \
  865. } while (0)
  866. #define REG_WRITE_ARRAY(iniarray, column, regWr) do { \
  867. int r; \
  868. for (r = 0; r < ((iniarray)->ia_rows); r++) { \
  869. REG_WRITE(ah, INI_RA((iniarray), (r), 0), \
  870. INI_RA((iniarray), r, (column))); \
  871. DO_DELAY(regWr); \
  872. } \
  873. } while (0)
  874. #define BASE_ACTIVATE_DELAY 100
  875. #define RTC_PLL_SETTLE_DELAY 1000
  876. #define COEF_SCALE_S 24
  877. #define HT40_CHANNEL_CENTER_SHIFT 10
  878. #define AR5416_EEPROM_MAGIC_OFFSET 0x0
  879. #define AR5416_EEPROM_S 2
  880. #define AR5416_EEPROM_OFFSET 0x2000
  881. #define AR5416_EEPROM_START_ADDR \
  882. (AR_SREV_9100(ah)) ? 0x1fff1000 : 0x503f1200
  883. #define AR5416_EEPROM_MAX 0xae0
  884. #define ar5416_get_eep_ver(_ahp) \
  885. (((_ahp)->ah_eeprom.def.baseEepHeader.version >> 12) & 0xF)
  886. #define ar5416_get_eep_rev(_ahp) \
  887. (((_ahp)->ah_eeprom.def.baseEepHeader.version) & 0xFFF)
  888. #define ar5416_get_ntxchains(_txchainmask) \
  889. (((_txchainmask >> 2) & 1) + \
  890. ((_txchainmask >> 1) & 1) + (_txchainmask & 1))
  891. /* EEPROM 4K bit map definations */
  892. #define ar5416_get_eep4k_ver(_ahp) \
  893. (((_ahp)->ah_eeprom.map4k.baseEepHeader.version >> 12) & 0xF)
  894. #define ar5416_get_eep4k_rev(_ahp) \
  895. (((_ahp)->ah_eeprom.map4k.baseEepHeader.version) & 0xFFF)
  896. #ifdef __BIG_ENDIAN
  897. #define AR5416_EEPROM_MAGIC 0x5aa5
  898. #else
  899. #define AR5416_EEPROM_MAGIC 0xa55a
  900. #endif
  901. #define ATH9K_POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
  902. #define ATH9K_ANTENNA0_CHAINMASK 0x1
  903. #define ATH9K_ANTENNA1_CHAINMASK 0x2
  904. #define ATH9K_NUM_DMA_DEBUG_REGS 8
  905. #define ATH9K_NUM_QUEUES 10
  906. #define HAL_NOISE_IMMUNE_MAX 4
  907. #define HAL_SPUR_IMMUNE_MAX 7
  908. #define HAL_FIRST_STEP_MAX 2
  909. #define ATH9K_ANI_OFDM_TRIG_HIGH 500
  910. #define ATH9K_ANI_OFDM_TRIG_LOW 200
  911. #define ATH9K_ANI_CCK_TRIG_HIGH 200
  912. #define ATH9K_ANI_CCK_TRIG_LOW 100
  913. #define ATH9K_ANI_NOISE_IMMUNE_LVL 4
  914. #define ATH9K_ANI_USE_OFDM_WEAK_SIG true
  915. #define ATH9K_ANI_CCK_WEAK_SIG_THR false
  916. #define ATH9K_ANI_SPUR_IMMUNE_LVL 7
  917. #define ATH9K_ANI_FIRSTEP_LVL 0
  918. #define ATH9K_ANI_RSSI_THR_HIGH 40
  919. #define ATH9K_ANI_RSSI_THR_LOW 7
  920. #define ATH9K_ANI_PERIOD 100
  921. #define AR_GPIOD_MASK 0x00001FFF
  922. #define AR_GPIO_BIT(_gpio) (1 << (_gpio))
  923. #define HAL_EP_RND(x, mul) \
  924. ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
  925. #define BEACON_RSSI(ahp) \
  926. HAL_EP_RND(ahp->ah_stats.ast_nodestats.ns_avgbrssi, \
  927. ATH9K_RSSI_EP_MULTIPLIER)
  928. #define ah_mibStats ah_stats.ast_mibstats
  929. #define AH_TIMEOUT 100000
  930. #define AH_TIME_QUANTUM 10
  931. #define AR_KEYTABLE_SIZE 128
  932. #define POWER_UP_TIME 200000
  933. #define EXT_ADDITIVE (0x8000)
  934. #define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
  935. #define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
  936. #define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
  937. #define SUB_NUM_CTL_MODES_AT_5G_40 2
  938. #define SUB_NUM_CTL_MODES_AT_2G_40 3
  939. #define SPUR_RSSI_THRESH 40
  940. #define TU_TO_USEC(_tu) ((_tu) << 10)
  941. #define CAB_TIMEOUT_VAL 10
  942. #define BEACON_TIMEOUT_VAL 10
  943. #define MIN_BEACON_TIMEOUT_VAL 1
  944. #define SLEEP_SLOP 3
  945. #define CCK_SIFS_TIME 10
  946. #define CCK_PREAMBLE_BITS 144
  947. #define CCK_PLCP_BITS 48
  948. #define OFDM_SIFS_TIME 16
  949. #define OFDM_PREAMBLE_TIME 20
  950. #define OFDM_PLCP_BITS 22
  951. #define OFDM_SYMBOL_TIME 4
  952. #define OFDM_SIFS_TIME_HALF 32
  953. #define OFDM_PREAMBLE_TIME_HALF 40
  954. #define OFDM_PLCP_BITS_HALF 22
  955. #define OFDM_SYMBOL_TIME_HALF 8
  956. #define OFDM_SIFS_TIME_QUARTER 64
  957. #define OFDM_PREAMBLE_TIME_QUARTER 80
  958. #define OFDM_PLCP_BITS_QUARTER 22
  959. #define OFDM_SYMBOL_TIME_QUARTER 16
  960. u32 ath9k_hw_get_eeprom(struct ath_hal *ah,
  961. enum eeprom_param param);
  962. #endif