hw.h 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  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. #ifndef HW_H
  17. #define HW_H
  18. #include <linux/if_ether.h>
  19. #include <linux/delay.h>
  20. #include <linux/io.h>
  21. #include <linux/firmware.h>
  22. #include "mac.h"
  23. #include "ani.h"
  24. #include "eeprom.h"
  25. #include "calib.h"
  26. #include "reg.h"
  27. #include "reg_mci.h"
  28. #include "phy.h"
  29. #include "btcoex.h"
  30. #include "dynack.h"
  31. #include "../regd.h"
  32. #define ATHEROS_VENDOR_ID 0x168c
  33. #define AR5416_DEVID_PCI 0x0023
  34. #define AR5416_DEVID_PCIE 0x0024
  35. #define AR9160_DEVID_PCI 0x0027
  36. #define AR9280_DEVID_PCI 0x0029
  37. #define AR9280_DEVID_PCIE 0x002a
  38. #define AR9285_DEVID_PCIE 0x002b
  39. #define AR2427_DEVID_PCIE 0x002c
  40. #define AR9287_DEVID_PCI 0x002d
  41. #define AR9287_DEVID_PCIE 0x002e
  42. #define AR9300_DEVID_PCIE 0x0030
  43. #define AR9300_DEVID_AR9340 0x0031
  44. #define AR9300_DEVID_AR9485_PCIE 0x0032
  45. #define AR9300_DEVID_AR9580 0x0033
  46. #define AR9300_DEVID_AR9462 0x0034
  47. #define AR9300_DEVID_AR9330 0x0035
  48. #define AR9300_DEVID_QCA955X 0x0038
  49. #define AR9485_DEVID_AR1111 0x0037
  50. #define AR9300_DEVID_AR9565 0x0036
  51. #define AR9300_DEVID_AR953X 0x003d
  52. #define AR9300_DEVID_QCA956X 0x003f
  53. #define AR5416_AR9100_DEVID 0x000b
  54. #define AR_SUBVENDOR_ID_NOG 0x0e11
  55. #define AR_SUBVENDOR_ID_NEW_A 0x7065
  56. #define AR5416_MAGIC 0x19641014
  57. #define AR9280_COEX2WIRE_SUBSYSID 0x309b
  58. #define AT9285_COEX3WIRE_SA_SUBSYSID 0x30aa
  59. #define AT9285_COEX3WIRE_DA_SUBSYSID 0x30ab
  60. #define ATH_AMPDU_LIMIT_MAX (64 * 1024 - 1)
  61. #define ATH_DEFAULT_NOISE_FLOOR -95
  62. #define ATH9K_RSSI_BAD -128
  63. #define ATH9K_NUM_CHANNELS 38
  64. /* Register read/write primitives */
  65. #define REG_WRITE(_ah, _reg, _val) \
  66. (_ah)->reg_ops.write((_ah), (_val), (_reg))
  67. #define REG_READ(_ah, _reg) \
  68. (_ah)->reg_ops.read((_ah), (_reg))
  69. #define REG_READ_MULTI(_ah, _addr, _val, _cnt) \
  70. (_ah)->reg_ops.multi_read((_ah), (_addr), (_val), (_cnt))
  71. #define REG_RMW(_ah, _reg, _set, _clr) \
  72. (_ah)->reg_ops.rmw((_ah), (_reg), (_set), (_clr))
  73. #define ENABLE_REGWRITE_BUFFER(_ah) \
  74. do { \
  75. if ((_ah)->reg_ops.enable_write_buffer) \
  76. (_ah)->reg_ops.enable_write_buffer((_ah)); \
  77. } while (0)
  78. #define REGWRITE_BUFFER_FLUSH(_ah) \
  79. do { \
  80. if ((_ah)->reg_ops.write_flush) \
  81. (_ah)->reg_ops.write_flush((_ah)); \
  82. } while (0)
  83. #define ENABLE_REG_RMW_BUFFER(_ah) \
  84. do { \
  85. if ((_ah)->reg_ops.enable_rmw_buffer) \
  86. (_ah)->reg_ops.enable_rmw_buffer((_ah)); \
  87. } while (0)
  88. #define REG_RMW_BUFFER_FLUSH(_ah) \
  89. do { \
  90. if ((_ah)->reg_ops.rmw_flush) \
  91. (_ah)->reg_ops.rmw_flush((_ah)); \
  92. } while (0)
  93. #define PR_EEP(_s, _val) \
  94. do { \
  95. len += scnprintf(buf + len, size - len, "%20s : %10d\n",\
  96. _s, (_val)); \
  97. } while (0)
  98. #define SM(_v, _f) (((_v) << _f##_S) & _f)
  99. #define MS(_v, _f) (((_v) & _f) >> _f##_S)
  100. #define REG_RMW_FIELD(_a, _r, _f, _v) \
  101. REG_RMW(_a, _r, (((_v) << _f##_S) & _f), (_f))
  102. #define REG_READ_FIELD(_a, _r, _f) \
  103. (((REG_READ(_a, _r) & _f) >> _f##_S))
  104. #define REG_SET_BIT(_a, _r, _f) \
  105. REG_RMW(_a, _r, (_f), 0)
  106. #define REG_CLR_BIT(_a, _r, _f) \
  107. REG_RMW(_a, _r, 0, (_f))
  108. #define DO_DELAY(x) do { \
  109. if (((++(x) % 64) == 0) && \
  110. (ath9k_hw_common(ah)->bus_ops->ath_bus_type \
  111. != ATH_USB)) \
  112. udelay(1); \
  113. } while (0)
  114. #define REG_WRITE_ARRAY(iniarray, column, regWr) \
  115. ath9k_hw_write_array(ah, iniarray, column, &(regWr))
  116. #define REG_READ_ARRAY(ah, array, size) \
  117. ath9k_hw_read_array(ah, array, size)
  118. #define AR_GPIO_OUTPUT_MUX_AS_OUTPUT 0
  119. #define AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED 1
  120. #define AR_GPIO_OUTPUT_MUX_AS_PCIE_POWER_LED 2
  121. #define AR_GPIO_OUTPUT_MUX_AS_TX_FRAME 3
  122. #define AR_GPIO_OUTPUT_MUX_AS_RX_CLEAR_EXTERNAL 4
  123. #define AR_GPIO_OUTPUT_MUX_AS_MAC_NETWORK_LED 5
  124. #define AR_GPIO_OUTPUT_MUX_AS_MAC_POWER_LED 6
  125. #define AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_DATA 0x16
  126. #define AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_CLK 0x17
  127. #define AR_GPIO_OUTPUT_MUX_AS_MCI_BT_DATA 0x18
  128. #define AR_GPIO_OUTPUT_MUX_AS_MCI_BT_CLK 0x19
  129. #define AR_GPIO_OUTPUT_MUX_AS_WL_IN_TX 0x14
  130. #define AR_GPIO_OUTPUT_MUX_AS_WL_IN_RX 0x13
  131. #define AR_GPIO_OUTPUT_MUX_AS_BT_IN_TX 9
  132. #define AR_GPIO_OUTPUT_MUX_AS_BT_IN_RX 8
  133. #define AR_GPIO_OUTPUT_MUX_AS_RUCKUS_STROBE 0x1d
  134. #define AR_GPIO_OUTPUT_MUX_AS_RUCKUS_DATA 0x1e
  135. #define AR_GPIOD_MASK 0x00001FFF
  136. #define AR_GPIO_BIT(_gpio) (1 << (_gpio))
  137. #define BASE_ACTIVATE_DELAY 100
  138. #define RTC_PLL_SETTLE_DELAY (AR_SREV_9340(ah) ? 1000 : 100)
  139. #define COEF_SCALE_S 24
  140. #define HT40_CHANNEL_CENTER_SHIFT 10
  141. #define ATH9K_ANTENNA0_CHAINMASK 0x1
  142. #define ATH9K_ANTENNA1_CHAINMASK 0x2
  143. #define ATH9K_NUM_DMA_DEBUG_REGS 8
  144. #define ATH9K_NUM_QUEUES 10
  145. #define MAX_RATE_POWER 63
  146. #define AH_WAIT_TIMEOUT 100000 /* (us) */
  147. #define AH_TSF_WRITE_TIMEOUT 100 /* (us) */
  148. #define AH_TIME_QUANTUM 10
  149. #define AR_KEYTABLE_SIZE 128
  150. #define POWER_UP_TIME 10000
  151. #define SPUR_RSSI_THRESH 40
  152. #define UPPER_5G_SUB_BAND_START 5700
  153. #define MID_5G_SUB_BAND_START 5400
  154. #define CAB_TIMEOUT_VAL 10
  155. #define BEACON_TIMEOUT_VAL 10
  156. #define MIN_BEACON_TIMEOUT_VAL 1
  157. #define SLEEP_SLOP TU_TO_USEC(3)
  158. #define INIT_CONFIG_STATUS 0x00000000
  159. #define INIT_RSSI_THR 0x00000700
  160. #define INIT_BCON_CNTRL_REG 0x00000000
  161. #define TU_TO_USEC(_tu) ((_tu) << 10)
  162. #define ATH9K_HW_RX_HP_QDEPTH 16
  163. #define ATH9K_HW_RX_LP_QDEPTH 128
  164. #define PAPRD_GAIN_TABLE_ENTRIES 32
  165. #define PAPRD_TABLE_SZ 24
  166. #define PAPRD_IDEAL_AGC2_PWR_RANGE 0xe0
  167. /*
  168. * Wake on Wireless
  169. */
  170. /* Keep Alive Frame */
  171. #define KAL_FRAME_LEN 28
  172. #define KAL_FRAME_TYPE 0x2 /* data frame */
  173. #define KAL_FRAME_SUB_TYPE 0x4 /* null data frame */
  174. #define KAL_DURATION_ID 0x3d
  175. #define KAL_NUM_DATA_WORDS 6
  176. #define KAL_NUM_DESC_WORDS 12
  177. #define KAL_ANTENNA_MODE 1
  178. #define KAL_TO_DS 1
  179. #define KAL_DELAY 4 /* delay of 4ms between 2 KAL frames */
  180. #define KAL_TIMEOUT 900
  181. #define MAX_PATTERN_SIZE 256
  182. #define MAX_PATTERN_MASK_SIZE 32
  183. #define MAX_NUM_PATTERN 16
  184. #define MAX_NUM_PATTERN_LEGACY 8
  185. #define MAX_NUM_USER_PATTERN 6 /* deducting the disassociate and
  186. deauthenticate packets */
  187. /*
  188. * WoW trigger mapping to hardware code
  189. */
  190. #define AH_WOW_USER_PATTERN_EN BIT(0)
  191. #define AH_WOW_MAGIC_PATTERN_EN BIT(1)
  192. #define AH_WOW_LINK_CHANGE BIT(2)
  193. #define AH_WOW_BEACON_MISS BIT(3)
  194. enum ath_hw_txq_subtype {
  195. ATH_TXQ_AC_BK = 0,
  196. ATH_TXQ_AC_BE = 1,
  197. ATH_TXQ_AC_VI = 2,
  198. ATH_TXQ_AC_VO = 3,
  199. };
  200. enum ath_ini_subsys {
  201. ATH_INI_PRE = 0,
  202. ATH_INI_CORE,
  203. ATH_INI_POST,
  204. ATH_INI_NUM_SPLIT,
  205. };
  206. enum ath9k_hw_caps {
  207. ATH9K_HW_CAP_HT = BIT(0),
  208. ATH9K_HW_CAP_RFSILENT = BIT(1),
  209. ATH9K_HW_CAP_AUTOSLEEP = BIT(2),
  210. ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(3),
  211. ATH9K_HW_CAP_EDMA = BIT(4),
  212. ATH9K_HW_CAP_RAC_SUPPORTED = BIT(5),
  213. ATH9K_HW_CAP_LDPC = BIT(6),
  214. ATH9K_HW_CAP_FASTCLOCK = BIT(7),
  215. ATH9K_HW_CAP_SGI_20 = BIT(8),
  216. ATH9K_HW_CAP_ANT_DIV_COMB = BIT(10),
  217. ATH9K_HW_CAP_2GHZ = BIT(11),
  218. ATH9K_HW_CAP_5GHZ = BIT(12),
  219. ATH9K_HW_CAP_APM = BIT(13),
  220. #ifdef CONFIG_ATH9K_PCOEM
  221. ATH9K_HW_CAP_RTT = BIT(14),
  222. ATH9K_HW_CAP_MCI = BIT(15),
  223. ATH9K_HW_CAP_BT_ANT_DIV = BIT(17),
  224. #else
  225. ATH9K_HW_CAP_RTT = 0,
  226. ATH9K_HW_CAP_MCI = 0,
  227. ATH9K_HW_CAP_BT_ANT_DIV = 0,
  228. #endif
  229. ATH9K_HW_CAP_DFS = BIT(18),
  230. ATH9K_HW_CAP_PAPRD = BIT(19),
  231. ATH9K_HW_CAP_FCC_BAND_SWITCH = BIT(20),
  232. };
  233. /*
  234. * WoW device capabilities
  235. * @ATH9K_HW_WOW_DEVICE_CAPABLE: device revision is capable of WoW.
  236. * @ATH9K_HW_WOW_PATTERN_MATCH_EXACT: device is capable of matching
  237. * an exact user defined pattern or de-authentication/disassoc pattern.
  238. * @ATH9K_HW_WOW_PATTERN_MATCH_DWORD: device requires the first four
  239. * bytes of the pattern for user defined pattern, de-authentication and
  240. * disassociation patterns for all types of possible frames recieved
  241. * of those types.
  242. */
  243. struct ath9k_hw_wow {
  244. u32 wow_event_mask;
  245. u32 wow_event_mask2;
  246. u8 max_patterns;
  247. };
  248. struct ath9k_hw_capabilities {
  249. u32 hw_caps; /* ATH9K_HW_CAP_* from ath9k_hw_caps */
  250. u16 rts_aggr_limit;
  251. u8 tx_chainmask;
  252. u8 rx_chainmask;
  253. u8 chip_chainmask;
  254. u8 max_txchains;
  255. u8 max_rxchains;
  256. u8 num_gpio_pins;
  257. u8 rx_hp_qdepth;
  258. u8 rx_lp_qdepth;
  259. u8 rx_status_len;
  260. u8 tx_desc_len;
  261. u8 txs_len;
  262. };
  263. #define AR_NO_SPUR 0x8000
  264. #define AR_BASE_FREQ_2GHZ 2300
  265. #define AR_BASE_FREQ_5GHZ 4900
  266. #define AR_SPUR_FEEQ_BOUND_HT40 19
  267. #define AR_SPUR_FEEQ_BOUND_HT20 10
  268. enum ath9k_hw_hang_checks {
  269. HW_BB_WATCHDOG = BIT(0),
  270. HW_PHYRESTART_CLC_WAR = BIT(1),
  271. HW_BB_RIFS_HANG = BIT(2),
  272. HW_BB_DFS_HANG = BIT(3),
  273. HW_BB_RX_CLEAR_STUCK_HANG = BIT(4),
  274. HW_MAC_HANG = BIT(5),
  275. };
  276. #define AR_PCIE_PLL_PWRSAVE_CONTROL BIT(0)
  277. #define AR_PCIE_PLL_PWRSAVE_ON_D3 BIT(1)
  278. #define AR_PCIE_PLL_PWRSAVE_ON_D0 BIT(2)
  279. #define AR_PCIE_CDR_PWRSAVE_ON_D3 BIT(3)
  280. #define AR_PCIE_CDR_PWRSAVE_ON_D0 BIT(4)
  281. struct ath9k_ops_config {
  282. int dma_beacon_response_time;
  283. int sw_beacon_response_time;
  284. bool cwm_ignore_extcca;
  285. u32 pcie_waen;
  286. u8 analog_shiftreg;
  287. u32 ofdm_trig_low;
  288. u32 ofdm_trig_high;
  289. u32 cck_trig_high;
  290. u32 cck_trig_low;
  291. bool enable_paprd;
  292. int serialize_regmode;
  293. bool rx_intr_mitigation;
  294. bool tx_intr_mitigation;
  295. u8 max_txtrig_level;
  296. u16 ani_poll_interval; /* ANI poll interval in ms */
  297. u16 hw_hang_checks;
  298. u16 rimt_first;
  299. u16 rimt_last;
  300. /* Platform specific config */
  301. u32 aspm_l1_fix;
  302. u32 xlna_gpio;
  303. u32 ant_ctrl_comm2g_switch_enable;
  304. bool xatten_margin_cfg;
  305. bool alt_mingainidx;
  306. u8 pll_pwrsave;
  307. bool tx_gain_buffalo;
  308. bool led_active_high;
  309. };
  310. enum ath9k_int {
  311. ATH9K_INT_RX = 0x00000001,
  312. ATH9K_INT_RXDESC = 0x00000002,
  313. ATH9K_INT_RXHP = 0x00000001,
  314. ATH9K_INT_RXLP = 0x00000002,
  315. ATH9K_INT_RXNOFRM = 0x00000008,
  316. ATH9K_INT_RXEOL = 0x00000010,
  317. ATH9K_INT_RXORN = 0x00000020,
  318. ATH9K_INT_TX = 0x00000040,
  319. ATH9K_INT_TXDESC = 0x00000080,
  320. ATH9K_INT_TIM_TIMER = 0x00000100,
  321. ATH9K_INT_MCI = 0x00000200,
  322. ATH9K_INT_BB_WATCHDOG = 0x00000400,
  323. ATH9K_INT_TXURN = 0x00000800,
  324. ATH9K_INT_MIB = 0x00001000,
  325. ATH9K_INT_RXPHY = 0x00004000,
  326. ATH9K_INT_RXKCM = 0x00008000,
  327. ATH9K_INT_SWBA = 0x00010000,
  328. ATH9K_INT_BMISS = 0x00040000,
  329. ATH9K_INT_BNR = 0x00100000,
  330. ATH9K_INT_TIM = 0x00200000,
  331. ATH9K_INT_DTIM = 0x00400000,
  332. ATH9K_INT_DTIMSYNC = 0x00800000,
  333. ATH9K_INT_GPIO = 0x01000000,
  334. ATH9K_INT_CABEND = 0x02000000,
  335. ATH9K_INT_TSFOOR = 0x04000000,
  336. ATH9K_INT_GENTIMER = 0x08000000,
  337. ATH9K_INT_CST = 0x10000000,
  338. ATH9K_INT_GTT = 0x20000000,
  339. ATH9K_INT_FATAL = 0x40000000,
  340. ATH9K_INT_GLOBAL = 0x80000000,
  341. ATH9K_INT_BMISC = ATH9K_INT_TIM |
  342. ATH9K_INT_DTIM |
  343. ATH9K_INT_DTIMSYNC |
  344. ATH9K_INT_TSFOOR |
  345. ATH9K_INT_CABEND,
  346. ATH9K_INT_COMMON = ATH9K_INT_RXNOFRM |
  347. ATH9K_INT_RXDESC |
  348. ATH9K_INT_RXEOL |
  349. ATH9K_INT_RXORN |
  350. ATH9K_INT_TXURN |
  351. ATH9K_INT_TXDESC |
  352. ATH9K_INT_MIB |
  353. ATH9K_INT_RXPHY |
  354. ATH9K_INT_RXKCM |
  355. ATH9K_INT_SWBA |
  356. ATH9K_INT_BMISS |
  357. ATH9K_INT_GPIO,
  358. ATH9K_INT_NOCARD = 0xffffffff
  359. };
  360. #define MAX_RTT_TABLE_ENTRY 6
  361. #define MAX_IQCAL_MEASUREMENT 8
  362. #define MAX_CL_TAB_ENTRY 16
  363. #define CL_TAB_ENTRY(reg_base) (reg_base + (4 * j))
  364. enum ath9k_cal_flags {
  365. RTT_DONE,
  366. PAPRD_PACKET_SENT,
  367. PAPRD_DONE,
  368. NFCAL_PENDING,
  369. NFCAL_INTF,
  370. TXIQCAL_DONE,
  371. TXCLCAL_DONE,
  372. SW_PKDET_DONE,
  373. };
  374. struct ath9k_hw_cal_data {
  375. u16 channel;
  376. u16 channelFlags;
  377. unsigned long cal_flags;
  378. int32_t CalValid;
  379. int8_t iCoff;
  380. int8_t qCoff;
  381. u8 caldac[2];
  382. u16 small_signal_gain[AR9300_MAX_CHAINS];
  383. u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ];
  384. u32 num_measures[AR9300_MAX_CHAINS];
  385. int tx_corr_coeff[MAX_IQCAL_MEASUREMENT][AR9300_MAX_CHAINS];
  386. u32 tx_clcal[AR9300_MAX_CHAINS][MAX_CL_TAB_ENTRY];
  387. u32 rtt_table[AR9300_MAX_CHAINS][MAX_RTT_TABLE_ENTRY];
  388. struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS];
  389. };
  390. struct ath9k_channel {
  391. struct ieee80211_channel *chan;
  392. u16 channel;
  393. u16 channelFlags;
  394. s16 noisefloor;
  395. };
  396. #define CHANNEL_5GHZ BIT(0)
  397. #define CHANNEL_HALF BIT(1)
  398. #define CHANNEL_QUARTER BIT(2)
  399. #define CHANNEL_HT BIT(3)
  400. #define CHANNEL_HT40PLUS BIT(4)
  401. #define CHANNEL_HT40MINUS BIT(5)
  402. #define IS_CHAN_5GHZ(_c) (!!((_c)->channelFlags & CHANNEL_5GHZ))
  403. #define IS_CHAN_2GHZ(_c) (!IS_CHAN_5GHZ(_c))
  404. #define IS_CHAN_HALF_RATE(_c) (!!((_c)->channelFlags & CHANNEL_HALF))
  405. #define IS_CHAN_QUARTER_RATE(_c) (!!((_c)->channelFlags & CHANNEL_QUARTER))
  406. #define IS_CHAN_A_FAST_CLOCK(_ah, _c) \
  407. (IS_CHAN_5GHZ(_c) && ((_ah)->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK))
  408. #define IS_CHAN_HT(_c) ((_c)->channelFlags & CHANNEL_HT)
  409. #define IS_CHAN_HT20(_c) (IS_CHAN_HT(_c) && !IS_CHAN_HT40(_c))
  410. #define IS_CHAN_HT40(_c) \
  411. (!!((_c)->channelFlags & (CHANNEL_HT40PLUS | CHANNEL_HT40MINUS)))
  412. #define IS_CHAN_HT40PLUS(_c) ((_c)->channelFlags & CHANNEL_HT40PLUS)
  413. #define IS_CHAN_HT40MINUS(_c) ((_c)->channelFlags & CHANNEL_HT40MINUS)
  414. enum ath9k_power_mode {
  415. ATH9K_PM_AWAKE = 0,
  416. ATH9K_PM_FULL_SLEEP,
  417. ATH9K_PM_NETWORK_SLEEP,
  418. ATH9K_PM_UNDEFINED
  419. };
  420. enum ser_reg_mode {
  421. SER_REG_MODE_OFF = 0,
  422. SER_REG_MODE_ON = 1,
  423. SER_REG_MODE_AUTO = 2,
  424. };
  425. enum ath9k_rx_qtype {
  426. ATH9K_RX_QUEUE_HP,
  427. ATH9K_RX_QUEUE_LP,
  428. ATH9K_RX_QUEUE_MAX,
  429. };
  430. struct ath9k_beacon_state {
  431. u32 bs_nexttbtt;
  432. u32 bs_nextdtim;
  433. u32 bs_intval;
  434. #define ATH9K_TSFOOR_THRESHOLD 0x00004240 /* 16k us */
  435. u32 bs_dtimperiod;
  436. u16 bs_bmissthreshold;
  437. u32 bs_sleepduration;
  438. u32 bs_tsfoor_threshold;
  439. };
  440. struct chan_centers {
  441. u16 synth_center;
  442. u16 ctl_center;
  443. u16 ext_center;
  444. };
  445. enum {
  446. ATH9K_RESET_POWER_ON,
  447. ATH9K_RESET_WARM,
  448. ATH9K_RESET_COLD,
  449. };
  450. struct ath9k_hw_version {
  451. u32 magic;
  452. u16 devid;
  453. u16 subvendorid;
  454. u32 macVersion;
  455. u16 macRev;
  456. u16 phyRev;
  457. u16 analog5GhzRev;
  458. u16 analog2GhzRev;
  459. enum ath_usb_dev usbdev;
  460. };
  461. /* Generic TSF timer definitions */
  462. #define ATH_MAX_GEN_TIMER 16
  463. #define AR_GENTMR_BIT(_index) (1 << (_index))
  464. struct ath_gen_timer_configuration {
  465. u32 next_addr;
  466. u32 period_addr;
  467. u32 mode_addr;
  468. u32 mode_mask;
  469. };
  470. struct ath_gen_timer {
  471. void (*trigger)(void *arg);
  472. void (*overflow)(void *arg);
  473. void *arg;
  474. u8 index;
  475. };
  476. struct ath_gen_timer_table {
  477. struct ath_gen_timer *timers[ATH_MAX_GEN_TIMER];
  478. u16 timer_mask;
  479. bool tsf2_enabled;
  480. };
  481. struct ath_hw_antcomb_conf {
  482. u8 main_lna_conf;
  483. u8 alt_lna_conf;
  484. u8 fast_div_bias;
  485. u8 main_gaintb;
  486. u8 alt_gaintb;
  487. int lna1_lna2_delta;
  488. int lna1_lna2_switch_delta;
  489. u8 div_group;
  490. };
  491. /**
  492. * struct ath_hw_radar_conf - radar detection initialization parameters
  493. *
  494. * @pulse_inband: threshold for checking the ratio of in-band power
  495. * to total power for short radar pulses (half dB steps)
  496. * @pulse_inband_step: threshold for checking an in-band power to total
  497. * power ratio increase for short radar pulses (half dB steps)
  498. * @pulse_height: threshold for detecting the beginning of a short
  499. * radar pulse (dB step)
  500. * @pulse_rssi: threshold for detecting if a short radar pulse is
  501. * gone (dB step)
  502. * @pulse_maxlen: maximum pulse length (0.8 us steps)
  503. *
  504. * @radar_rssi: RSSI threshold for starting long radar detection (dB steps)
  505. * @radar_inband: threshold for checking the ratio of in-band power
  506. * to total power for long radar pulses (half dB steps)
  507. * @fir_power: threshold for detecting the end of a long radar pulse (dB)
  508. *
  509. * @ext_channel: enable extension channel radar detection
  510. */
  511. struct ath_hw_radar_conf {
  512. unsigned int pulse_inband;
  513. unsigned int pulse_inband_step;
  514. unsigned int pulse_height;
  515. unsigned int pulse_rssi;
  516. unsigned int pulse_maxlen;
  517. unsigned int radar_rssi;
  518. unsigned int radar_inband;
  519. int fir_power;
  520. bool ext_channel;
  521. };
  522. /**
  523. * struct ath_hw_private_ops - callbacks used internally by hardware code
  524. *
  525. * This structure contains private callbacks designed to only be used internally
  526. * by the hardware core.
  527. *
  528. * @init_cal_settings: setup types of calibrations supported
  529. * @init_cal: starts actual calibration
  530. *
  531. * @init_mode_gain_regs: Initialize TX/RX gain registers
  532. *
  533. * @rf_set_freq: change frequency
  534. * @spur_mitigate_freq: spur mitigation
  535. * @set_rf_regs:
  536. * @compute_pll_control: compute the PLL control value to use for
  537. * AR_RTC_PLL_CONTROL for a given channel
  538. * @setup_calibration: set up calibration
  539. * @iscal_supported: used to query if a type of calibration is supported
  540. *
  541. * @ani_cache_ini_regs: cache the values for ANI from the initial
  542. * register settings through the register initialization.
  543. */
  544. struct ath_hw_private_ops {
  545. void (*init_hang_checks)(struct ath_hw *ah);
  546. bool (*detect_mac_hang)(struct ath_hw *ah);
  547. bool (*detect_bb_hang)(struct ath_hw *ah);
  548. /* Calibration ops */
  549. void (*init_cal_settings)(struct ath_hw *ah);
  550. bool (*init_cal)(struct ath_hw *ah, struct ath9k_channel *chan);
  551. void (*init_mode_gain_regs)(struct ath_hw *ah);
  552. void (*setup_calibration)(struct ath_hw *ah,
  553. struct ath9k_cal_list *currCal);
  554. /* PHY ops */
  555. int (*rf_set_freq)(struct ath_hw *ah,
  556. struct ath9k_channel *chan);
  557. void (*spur_mitigate_freq)(struct ath_hw *ah,
  558. struct ath9k_channel *chan);
  559. bool (*set_rf_regs)(struct ath_hw *ah,
  560. struct ath9k_channel *chan,
  561. u16 modesIndex);
  562. void (*set_channel_regs)(struct ath_hw *ah, struct ath9k_channel *chan);
  563. void (*init_bb)(struct ath_hw *ah,
  564. struct ath9k_channel *chan);
  565. int (*process_ini)(struct ath_hw *ah, struct ath9k_channel *chan);
  566. void (*olc_init)(struct ath_hw *ah);
  567. void (*set_rfmode)(struct ath_hw *ah, struct ath9k_channel *chan);
  568. void (*mark_phy_inactive)(struct ath_hw *ah);
  569. void (*set_delta_slope)(struct ath_hw *ah, struct ath9k_channel *chan);
  570. bool (*rfbus_req)(struct ath_hw *ah);
  571. void (*rfbus_done)(struct ath_hw *ah);
  572. void (*restore_chainmask)(struct ath_hw *ah);
  573. u32 (*compute_pll_control)(struct ath_hw *ah,
  574. struct ath9k_channel *chan);
  575. bool (*ani_control)(struct ath_hw *ah, enum ath9k_ani_cmd cmd,
  576. int param);
  577. void (*do_getnf)(struct ath_hw *ah, int16_t nfarray[NUM_NF_READINGS]);
  578. void (*set_radar_params)(struct ath_hw *ah,
  579. struct ath_hw_radar_conf *conf);
  580. int (*fast_chan_change)(struct ath_hw *ah, struct ath9k_channel *chan,
  581. u8 *ini_reloaded);
  582. /* ANI */
  583. void (*ani_cache_ini_regs)(struct ath_hw *ah);
  584. #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
  585. bool (*is_aic_enabled)(struct ath_hw *ah);
  586. #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
  587. };
  588. /**
  589. * struct ath_spec_scan - parameters for Atheros spectral scan
  590. *
  591. * @enabled: enable/disable spectral scan
  592. * @short_repeat: controls whether the chip is in spectral scan mode
  593. * for 4 usec (enabled) or 204 usec (disabled)
  594. * @count: number of scan results requested. There are special meanings
  595. * in some chip revisions:
  596. * AR92xx: highest bit set (>=128) for endless mode
  597. * (spectral scan won't stopped until explicitly disabled)
  598. * AR9300 and newer: 0 for endless mode
  599. * @endless: true if endless mode is intended. Otherwise, count value is
  600. * corrected to the next possible value.
  601. * @period: time duration between successive spectral scan entry points
  602. * (period*256*Tclk). Tclk = ath_common->clockrate
  603. * @fft_period: PHY passes FFT frames to MAC every (fft_period+1)*4uS
  604. *
  605. * Note: Tclk = 40MHz or 44MHz depending upon operating mode.
  606. * Typically it's 44MHz in 2/5GHz on later chips, but there's
  607. * a "fast clock" check for this in 5GHz.
  608. *
  609. */
  610. struct ath_spec_scan {
  611. bool enabled;
  612. bool short_repeat;
  613. bool endless;
  614. u8 count;
  615. u8 period;
  616. u8 fft_period;
  617. };
  618. /**
  619. * struct ath_hw_ops - callbacks used by hardware code and driver code
  620. *
  621. * This structure contains callbacks designed to to be used internally by
  622. * hardware code and also by the lower level driver.
  623. *
  624. * @config_pci_powersave:
  625. * @calibrate: periodic calibration for NF, ANI, IQ, ADC gain, ADC-DC
  626. *
  627. * @spectral_scan_config: set parameters for spectral scan and enable/disable it
  628. * @spectral_scan_trigger: trigger a spectral scan run
  629. * @spectral_scan_wait: wait for a spectral scan run to finish
  630. */
  631. struct ath_hw_ops {
  632. void (*config_pci_powersave)(struct ath_hw *ah,
  633. bool power_off);
  634. void (*rx_enable)(struct ath_hw *ah);
  635. void (*set_desc_link)(void *ds, u32 link);
  636. int (*calibrate)(struct ath_hw *ah, struct ath9k_channel *chan,
  637. u8 rxchainmask, bool longcal);
  638. bool (*get_isr)(struct ath_hw *ah, enum ath9k_int *masked,
  639. u32 *sync_cause_p);
  640. void (*set_txdesc)(struct ath_hw *ah, void *ds,
  641. struct ath_tx_info *i);
  642. int (*proc_txdesc)(struct ath_hw *ah, void *ds,
  643. struct ath_tx_status *ts);
  644. int (*get_duration)(struct ath_hw *ah, const void *ds, int index);
  645. void (*antdiv_comb_conf_get)(struct ath_hw *ah,
  646. struct ath_hw_antcomb_conf *antconf);
  647. void (*antdiv_comb_conf_set)(struct ath_hw *ah,
  648. struct ath_hw_antcomb_conf *antconf);
  649. void (*spectral_scan_config)(struct ath_hw *ah,
  650. struct ath_spec_scan *param);
  651. void (*spectral_scan_trigger)(struct ath_hw *ah);
  652. void (*spectral_scan_wait)(struct ath_hw *ah);
  653. void (*tx99_start)(struct ath_hw *ah, u32 qnum);
  654. void (*tx99_stop)(struct ath_hw *ah);
  655. void (*tx99_set_txpower)(struct ath_hw *ah, u8 power);
  656. #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
  657. void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
  658. #endif
  659. };
  660. struct ath_nf_limits {
  661. s16 max;
  662. s16 min;
  663. s16 nominal;
  664. };
  665. enum ath_cal_list {
  666. TX_IQ_CAL = BIT(0),
  667. TX_IQ_ON_AGC_CAL = BIT(1),
  668. TX_CL_CAL = BIT(2),
  669. };
  670. /* ah_flags */
  671. #define AH_USE_EEPROM 0x1
  672. #define AH_UNPLUGGED 0x2 /* The card has been physically removed. */
  673. #define AH_FASTCC 0x4
  674. #define AH_NO_EEP_SWAP 0x8 /* Do not swap EEPROM data */
  675. struct ath_hw {
  676. struct ath_ops reg_ops;
  677. struct device *dev;
  678. struct ieee80211_hw *hw;
  679. struct ath_common common;
  680. struct ath9k_hw_version hw_version;
  681. struct ath9k_ops_config config;
  682. struct ath9k_hw_capabilities caps;
  683. struct ath9k_channel channels[ATH9K_NUM_CHANNELS];
  684. struct ath9k_channel *curchan;
  685. union {
  686. struct ar5416_eeprom_def def;
  687. struct ar5416_eeprom_4k map4k;
  688. struct ar9287_eeprom map9287;
  689. struct ar9300_eeprom ar9300_eep;
  690. } eeprom;
  691. const struct eeprom_ops *eep_ops;
  692. bool sw_mgmt_crypto_tx;
  693. bool sw_mgmt_crypto_rx;
  694. bool is_pciexpress;
  695. bool aspm_enabled;
  696. bool is_monitoring;
  697. bool need_an_top2_fixup;
  698. u16 tx_trig_level;
  699. u32 nf_regs[6];
  700. struct ath_nf_limits nf_2g;
  701. struct ath_nf_limits nf_5g;
  702. u16 rfsilent;
  703. u32 rfkill_gpio;
  704. u32 rfkill_polarity;
  705. u32 ah_flags;
  706. bool reset_power_on;
  707. bool htc_reset_init;
  708. enum nl80211_iftype opmode;
  709. enum ath9k_power_mode power_mode;
  710. s8 noise;
  711. struct ath9k_hw_cal_data *caldata;
  712. struct ath9k_pacal_info pacal_info;
  713. struct ar5416Stats stats;
  714. struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES];
  715. enum ath9k_int imask;
  716. u32 imrs2_reg;
  717. u32 txok_interrupt_mask;
  718. u32 txerr_interrupt_mask;
  719. u32 txdesc_interrupt_mask;
  720. u32 txeol_interrupt_mask;
  721. u32 txurn_interrupt_mask;
  722. atomic_t intr_ref_cnt;
  723. bool chip_fullsleep;
  724. u32 modes_index;
  725. /* Calibration */
  726. u32 supp_cals;
  727. struct ath9k_cal_list iq_caldata;
  728. struct ath9k_cal_list adcgain_caldata;
  729. struct ath9k_cal_list adcdc_caldata;
  730. struct ath9k_cal_list *cal_list;
  731. struct ath9k_cal_list *cal_list_last;
  732. struct ath9k_cal_list *cal_list_curr;
  733. #define totalPowerMeasI meas0.unsign
  734. #define totalPowerMeasQ meas1.unsign
  735. #define totalIqCorrMeas meas2.sign
  736. #define totalAdcIOddPhase meas0.unsign
  737. #define totalAdcIEvenPhase meas1.unsign
  738. #define totalAdcQOddPhase meas2.unsign
  739. #define totalAdcQEvenPhase meas3.unsign
  740. #define totalAdcDcOffsetIOddPhase meas0.sign
  741. #define totalAdcDcOffsetIEvenPhase meas1.sign
  742. #define totalAdcDcOffsetQOddPhase meas2.sign
  743. #define totalAdcDcOffsetQEvenPhase meas3.sign
  744. union {
  745. u32 unsign[AR5416_MAX_CHAINS];
  746. int32_t sign[AR5416_MAX_CHAINS];
  747. } meas0;
  748. union {
  749. u32 unsign[AR5416_MAX_CHAINS];
  750. int32_t sign[AR5416_MAX_CHAINS];
  751. } meas1;
  752. union {
  753. u32 unsign[AR5416_MAX_CHAINS];
  754. int32_t sign[AR5416_MAX_CHAINS];
  755. } meas2;
  756. union {
  757. u32 unsign[AR5416_MAX_CHAINS];
  758. int32_t sign[AR5416_MAX_CHAINS];
  759. } meas3;
  760. u16 cal_samples;
  761. u8 enabled_cals;
  762. u32 sta_id1_defaults;
  763. u32 misc_mode;
  764. /* Private to hardware code */
  765. struct ath_hw_private_ops private_ops;
  766. /* Accessed by the lower level driver */
  767. struct ath_hw_ops ops;
  768. /* Used to program the radio on non single-chip devices */
  769. u32 *analogBank6Data;
  770. int coverage_class;
  771. u32 slottime;
  772. u32 globaltxtimeout;
  773. /* ANI */
  774. u32 aniperiod;
  775. enum ath9k_ani_cmd ani_function;
  776. u32 ani_skip_count;
  777. struct ar5416AniState ani;
  778. #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
  779. struct ath_btcoex_hw btcoex_hw;
  780. #endif
  781. u32 intr_txqs;
  782. u8 txchainmask;
  783. u8 rxchainmask;
  784. struct ath_hw_radar_conf radar_conf;
  785. u32 originalGain[22];
  786. int initPDADC;
  787. int PDADCdelta;
  788. int led_pin;
  789. u32 gpio_mask;
  790. u32 gpio_val;
  791. struct ar5416IniArray ini_dfs;
  792. struct ar5416IniArray iniModes;
  793. struct ar5416IniArray iniCommon;
  794. struct ar5416IniArray iniBB_RfGain;
  795. struct ar5416IniArray iniBank6;
  796. struct ar5416IniArray iniAddac;
  797. struct ar5416IniArray iniPcieSerdes;
  798. struct ar5416IniArray iniPcieSerdesLowPower;
  799. struct ar5416IniArray iniModesFastClock;
  800. struct ar5416IniArray iniAdditional;
  801. struct ar5416IniArray iniModesRxGain;
  802. struct ar5416IniArray ini_modes_rx_gain_bounds;
  803. struct ar5416IniArray iniModesTxGain;
  804. struct ar5416IniArray iniCckfirNormal;
  805. struct ar5416IniArray iniCckfirJapan2484;
  806. struct ar5416IniArray iniModes_9271_ANI_reg;
  807. struct ar5416IniArray ini_radio_post_sys2ant;
  808. struct ar5416IniArray ini_modes_rxgain_xlna;
  809. struct ar5416IniArray ini_modes_rxgain_bb_core;
  810. struct ar5416IniArray ini_modes_rxgain_bb_postamble;
  811. struct ar5416IniArray iniMac[ATH_INI_NUM_SPLIT];
  812. struct ar5416IniArray iniBB[ATH_INI_NUM_SPLIT];
  813. struct ar5416IniArray iniRadio[ATH_INI_NUM_SPLIT];
  814. struct ar5416IniArray iniSOC[ATH_INI_NUM_SPLIT];
  815. u32 intr_gen_timer_trigger;
  816. u32 intr_gen_timer_thresh;
  817. struct ath_gen_timer_table hw_gen_timers;
  818. struct ar9003_txs *ts_ring;
  819. u32 ts_paddr_start;
  820. u32 ts_paddr_end;
  821. u16 ts_tail;
  822. u16 ts_size;
  823. u32 bb_watchdog_last_status;
  824. u32 bb_watchdog_timeout_ms; /* in ms, 0 to disable */
  825. u8 bb_hang_rx_ofdm; /* true if bb hang due to rx_ofdm */
  826. unsigned int paprd_target_power;
  827. unsigned int paprd_training_power;
  828. unsigned int paprd_ratemask;
  829. unsigned int paprd_ratemask_ht40;
  830. bool paprd_table_write_done;
  831. u32 paprd_gain_table_entries[PAPRD_GAIN_TABLE_ENTRIES];
  832. u8 paprd_gain_table_index[PAPRD_GAIN_TABLE_ENTRIES];
  833. /*
  834. * Store the permanent value of Reg 0x4004in WARegVal
  835. * so we dont have to R/M/W. We should not be reading
  836. * this register when in sleep states.
  837. */
  838. u32 WARegVal;
  839. /* Enterprise mode cap */
  840. u32 ent_mode;
  841. #ifdef CONFIG_ATH9K_WOW
  842. struct ath9k_hw_wow wow;
  843. #endif
  844. bool is_clk_25mhz;
  845. int (*get_mac_revision)(void);
  846. int (*external_reset)(void);
  847. bool disable_2ghz;
  848. bool disable_5ghz;
  849. const struct firmware *eeprom_blob;
  850. struct ath_dynack dynack;
  851. bool tpc_enabled;
  852. u8 tx_power[Ar5416RateSize];
  853. u8 tx_power_stbc[Ar5416RateSize];
  854. };
  855. struct ath_bus_ops {
  856. enum ath_bus_type ath_bus_type;
  857. void (*read_cachesize)(struct ath_common *common, int *csz);
  858. bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
  859. void (*bt_coex_prep)(struct ath_common *common);
  860. void (*aspm_init)(struct ath_common *common);
  861. };
  862. static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah)
  863. {
  864. return &ah->common;
  865. }
  866. static inline struct ath_regulatory *ath9k_hw_regulatory(struct ath_hw *ah)
  867. {
  868. return &(ath9k_hw_common(ah)->regulatory);
  869. }
  870. static inline struct ath_hw_private_ops *ath9k_hw_private_ops(struct ath_hw *ah)
  871. {
  872. return &ah->private_ops;
  873. }
  874. static inline struct ath_hw_ops *ath9k_hw_ops(struct ath_hw *ah)
  875. {
  876. return &ah->ops;
  877. }
  878. static inline u8 get_streams(int mask)
  879. {
  880. return !!(mask & BIT(0)) + !!(mask & BIT(1)) + !!(mask & BIT(2));
  881. }
  882. /* Initialization, Detach, Reset */
  883. void ath9k_hw_deinit(struct ath_hw *ah);
  884. int ath9k_hw_init(struct ath_hw *ah);
  885. int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
  886. struct ath9k_hw_cal_data *caldata, bool fastcc);
  887. int ath9k_hw_fill_cap_info(struct ath_hw *ah);
  888. u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan);
  889. /* GPIO / RFKILL / Antennae */
  890. void ath9k_hw_cfg_gpio_input(struct ath_hw *ah, u32 gpio);
  891. u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio);
  892. void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio,
  893. u32 ah_signal_type);
  894. void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val);
  895. void ath9k_hw_request_gpio(struct ath_hw *ah, u32 gpio, const char *label);
  896. void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna);
  897. /* General Operation */
  898. void ath9k_hw_synth_delay(struct ath_hw *ah, struct ath9k_channel *chan,
  899. int hw_delay);
  900. bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout);
  901. void ath9k_hw_write_array(struct ath_hw *ah, const struct ar5416IniArray *array,
  902. int column, unsigned int *writecnt);
  903. void ath9k_hw_read_array(struct ath_hw *ah, u32 array[][2], int size);
  904. u32 ath9k_hw_reverse_bits(u32 val, u32 n);
  905. u16 ath9k_hw_computetxtime(struct ath_hw *ah,
  906. u8 phy, int kbps,
  907. u32 frameLen, u16 rateix, bool shortPreamble);
  908. void ath9k_hw_get_channel_centers(struct ath_hw *ah,
  909. struct ath9k_channel *chan,
  910. struct chan_centers *centers);
  911. u32 ath9k_hw_getrxfilter(struct ath_hw *ah);
  912. void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits);
  913. bool ath9k_hw_phy_disable(struct ath_hw *ah);
  914. bool ath9k_hw_disable(struct ath_hw *ah);
  915. void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test);
  916. void ath9k_hw_setopmode(struct ath_hw *ah);
  917. void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1);
  918. void ath9k_hw_write_associd(struct ath_hw *ah);
  919. u32 ath9k_hw_gettsf32(struct ath_hw *ah);
  920. u64 ath9k_hw_gettsf64(struct ath_hw *ah);
  921. void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64);
  922. void ath9k_hw_reset_tsf(struct ath_hw *ah);
  923. u32 ath9k_hw_get_tsf_offset(struct timespec *last, struct timespec *cur);
  924. void ath9k_hw_set_tsfadjust(struct ath_hw *ah, bool set);
  925. void ath9k_hw_init_global_settings(struct ath_hw *ah);
  926. u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah);
  927. void ath9k_hw_set11nmac2040(struct ath_hw *ah, struct ath9k_channel *chan);
  928. void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period);
  929. void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
  930. const struct ath9k_beacon_state *bs);
  931. void ath9k_hw_check_nav(struct ath_hw *ah);
  932. bool ath9k_hw_check_alive(struct ath_hw *ah);
  933. bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode);
  934. /* Generic hw timer primitives */
  935. struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
  936. void (*trigger)(void *),
  937. void (*overflow)(void *),
  938. void *arg,
  939. u8 timer_index);
  940. void ath9k_hw_gen_timer_start(struct ath_hw *ah,
  941. struct ath_gen_timer *timer,
  942. u32 timer_next,
  943. u32 timer_period);
  944. void ath9k_hw_gen_timer_start_tsf2(struct ath_hw *ah);
  945. void ath9k_hw_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer);
  946. void ath_gen_timer_free(struct ath_hw *ah, struct ath_gen_timer *timer);
  947. void ath_gen_timer_isr(struct ath_hw *hw);
  948. void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len);
  949. /* PHY */
  950. void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled,
  951. u32 *coef_mantissa, u32 *coef_exponent);
  952. void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan,
  953. bool test);
  954. /*
  955. * Code Specific to AR5008, AR9001 or AR9002,
  956. * we stuff these here to avoid callbacks for AR9003.
  957. */
  958. int ar9002_hw_rf_claim(struct ath_hw *ah);
  959. void ar9002_hw_enable_async_fifo(struct ath_hw *ah);
  960. /*
  961. * Code specific to AR9003, we stuff these here to avoid callbacks
  962. * for older families
  963. */
  964. bool ar9003_hw_bb_watchdog_check(struct ath_hw *ah);
  965. void ar9003_hw_bb_watchdog_config(struct ath_hw *ah);
  966. void ar9003_hw_bb_watchdog_read(struct ath_hw *ah);
  967. void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah);
  968. void ar9003_hw_disable_phy_restart(struct ath_hw *ah);
  969. void ar9003_paprd_enable(struct ath_hw *ah, bool val);
  970. void ar9003_paprd_populate_single_table(struct ath_hw *ah,
  971. struct ath9k_hw_cal_data *caldata,
  972. int chain);
  973. int ar9003_paprd_create_curve(struct ath_hw *ah,
  974. struct ath9k_hw_cal_data *caldata, int chain);
  975. void ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain);
  976. int ar9003_paprd_init_table(struct ath_hw *ah);
  977. bool ar9003_paprd_is_done(struct ath_hw *ah);
  978. bool ar9003_is_paprd_enabled(struct ath_hw *ah);
  979. void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx);
  980. void ar9003_hw_init_rate_txpower(struct ath_hw *ah, u8 *rate_array,
  981. struct ath9k_channel *chan);
  982. void ar5008_hw_cmn_spur_mitigate(struct ath_hw *ah,
  983. struct ath9k_channel *chan, int bin);
  984. void ar5008_hw_init_rate_txpower(struct ath_hw *ah, int16_t *rate_array,
  985. struct ath9k_channel *chan, int ht40_delta);
  986. /* Hardware family op attach helpers */
  987. int ar5008_hw_attach_phy_ops(struct ath_hw *ah);
  988. void ar9002_hw_attach_phy_ops(struct ath_hw *ah);
  989. void ar9003_hw_attach_phy_ops(struct ath_hw *ah);
  990. void ar9002_hw_attach_calib_ops(struct ath_hw *ah);
  991. void ar9003_hw_attach_calib_ops(struct ath_hw *ah);
  992. int ar9002_hw_attach_ops(struct ath_hw *ah);
  993. void ar9003_hw_attach_ops(struct ath_hw *ah);
  994. void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan);
  995. void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning);
  996. void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan);
  997. void ath9k_hw_set_ack_timeout(struct ath_hw *ah, u32 us);
  998. void ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us);
  999. void ath9k_hw_setslottime(struct ath_hw *ah, u32 us);
  1000. #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
  1001. void ar9003_hw_attach_aic_ops(struct ath_hw *ah);
  1002. static inline bool ath9k_hw_btcoex_is_enabled(struct ath_hw *ah)
  1003. {
  1004. return ah->btcoex_hw.enabled;
  1005. }
  1006. static inline bool ath9k_hw_mci_is_enabled(struct ath_hw *ah)
  1007. {
  1008. return ah->common.btcoex_enabled &&
  1009. (ah->caps.hw_caps & ATH9K_HW_CAP_MCI);
  1010. }
  1011. void ath9k_hw_btcoex_enable(struct ath_hw *ah);
  1012. static inline enum ath_btcoex_scheme
  1013. ath9k_hw_get_btcoex_scheme(struct ath_hw *ah)
  1014. {
  1015. return ah->btcoex_hw.scheme;
  1016. }
  1017. #else
  1018. static inline void ar9003_hw_attach_aic_ops(struct ath_hw *ah)
  1019. {
  1020. }
  1021. static inline bool ath9k_hw_btcoex_is_enabled(struct ath_hw *ah)
  1022. {
  1023. return false;
  1024. }
  1025. static inline bool ath9k_hw_mci_is_enabled(struct ath_hw *ah)
  1026. {
  1027. return false;
  1028. }
  1029. static inline void ath9k_hw_btcoex_enable(struct ath_hw *ah)
  1030. {
  1031. }
  1032. static inline enum ath_btcoex_scheme
  1033. ath9k_hw_get_btcoex_scheme(struct ath_hw *ah)
  1034. {
  1035. return ATH_BTCOEX_CFG_NONE;
  1036. }
  1037. #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
  1038. #ifdef CONFIG_ATH9K_WOW
  1039. int ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern,
  1040. u8 *user_mask, int pattern_count,
  1041. int pattern_len);
  1042. u32 ath9k_hw_wow_wakeup(struct ath_hw *ah);
  1043. void ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable);
  1044. #else
  1045. static inline int ath9k_hw_wow_apply_pattern(struct ath_hw *ah,
  1046. u8 *user_pattern,
  1047. u8 *user_mask,
  1048. int pattern_count,
  1049. int pattern_len)
  1050. {
  1051. return 0;
  1052. }
  1053. static inline u32 ath9k_hw_wow_wakeup(struct ath_hw *ah)
  1054. {
  1055. return 0;
  1056. }
  1057. static inline void ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable)
  1058. {
  1059. }
  1060. #endif
  1061. #define ATH9K_CLOCK_RATE_CCK 22
  1062. #define ATH9K_CLOCK_RATE_5GHZ_OFDM 40
  1063. #define ATH9K_CLOCK_RATE_2GHZ_OFDM 44
  1064. #define ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM 44
  1065. #endif