phy_int.h 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. /*
  2. * Copyright (c) 2010 Broadcom Corporation
  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 ANY
  11. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  13. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef _BRCM_PHY_INT_H_
  17. #define _BRCM_PHY_INT_H_
  18. #include <types.h>
  19. #include <brcmu_utils.h>
  20. #include <brcmu_wifi.h>
  21. #define PHY_VERSION { 1, 82, 8, 0 }
  22. #define LCNXN_BASEREV 16
  23. struct phy_shim_info;
  24. struct brcms_phy_srom_fem {
  25. /* TSSI positive slope, 1: positive, 0: negative */
  26. u8 tssipos;
  27. /* Ext PA gain-type: full-gain: 0, pa-lite: 1, no_pa: 2 */
  28. u8 extpagain;
  29. /* support 32 combinations of different Pdet dynamic ranges */
  30. u8 pdetrange;
  31. /* TR switch isolation */
  32. u8 triso;
  33. /* antswctrl lookup table configuration: 32 possible choices */
  34. u8 antswctrllut;
  35. };
  36. #define ISNPHY(pi) PHYTYPE_IS((pi)->pubpi.phy_type, PHY_TYPE_N)
  37. #define ISLCNPHY(pi) PHYTYPE_IS((pi)->pubpi.phy_type, PHY_TYPE_LCN)
  38. #define PHY_GET_RFATTN(rfgain) ((rfgain) & 0x0f)
  39. #define PHY_GET_PADMIX(rfgain) (((rfgain) & 0x10) >> 4)
  40. #define PHY_GET_RFGAINID(rfattn, padmix, width) ((rfattn) + ((padmix)*(width)))
  41. #define PHY_SAT(x, n) ((x) > ((1<<((n)-1))-1) ? ((1<<((n)-1))-1) : \
  42. ((x) < -(1<<((n)-1)) ? -(1<<((n)-1)) : (x)))
  43. #define PHY_SHIFT_ROUND(x, n) ((x) >= 0 ? ((x)+(1<<((n)-1)))>>(n) : (x)>>(n))
  44. #define PHY_HW_ROUND(x, s) ((x >> s) + ((x >> (s-1)) & (s != 0)))
  45. #define CH_5G_GROUP 3
  46. #define A_LOW_CHANS 0
  47. #define A_MID_CHANS 1
  48. #define A_HIGH_CHANS 2
  49. #define CH_2G_GROUP 1
  50. #define G_ALL_CHANS 0
  51. #define FIRST_REF5_CHANNUM 149
  52. #define LAST_REF5_CHANNUM 165
  53. #define FIRST_5G_CHAN 14
  54. #define LAST_5G_CHAN 50
  55. #define FIRST_MID_5G_CHAN 14
  56. #define LAST_MID_5G_CHAN 35
  57. #define FIRST_HIGH_5G_CHAN 36
  58. #define LAST_HIGH_5G_CHAN 41
  59. #define FIRST_LOW_5G_CHAN 42
  60. #define LAST_LOW_5G_CHAN 50
  61. #define BASE_LOW_5G_CHAN 4900
  62. #define BASE_MID_5G_CHAN 5100
  63. #define BASE_HIGH_5G_CHAN 5500
  64. #define CHAN5G_FREQ(chan) (5000 + chan*5)
  65. #define CHAN2G_FREQ(chan) (2407 + chan*5)
  66. #define TXP_FIRST_CCK 0
  67. #define TXP_LAST_CCK 3
  68. #define TXP_FIRST_OFDM 4
  69. #define TXP_LAST_OFDM 11
  70. #define TXP_FIRST_OFDM_20_CDD 12
  71. #define TXP_LAST_OFDM_20_CDD 19
  72. #define TXP_FIRST_MCS_20_SISO 20
  73. #define TXP_LAST_MCS_20_SISO 27
  74. #define TXP_FIRST_MCS_20_CDD 28
  75. #define TXP_LAST_MCS_20_CDD 35
  76. #define TXP_FIRST_MCS_20_STBC 36
  77. #define TXP_LAST_MCS_20_STBC 43
  78. #define TXP_FIRST_MCS_20_SDM 44
  79. #define TXP_LAST_MCS_20_SDM 51
  80. #define TXP_FIRST_OFDM_40_SISO 52
  81. #define TXP_LAST_OFDM_40_SISO 59
  82. #define TXP_FIRST_OFDM_40_CDD 60
  83. #define TXP_LAST_OFDM_40_CDD 67
  84. #define TXP_FIRST_MCS_40_SISO 68
  85. #define TXP_LAST_MCS_40_SISO 75
  86. #define TXP_FIRST_MCS_40_CDD 76
  87. #define TXP_LAST_MCS_40_CDD 83
  88. #define TXP_FIRST_MCS_40_STBC 84
  89. #define TXP_LAST_MCS_40_STBC 91
  90. #define TXP_FIRST_MCS_40_SDM 92
  91. #define TXP_LAST_MCS_40_SDM 99
  92. #define TXP_MCS_32 100
  93. #define TXP_NUM_RATES 101
  94. #define ADJ_PWR_TBL_LEN 84
  95. #define TXP_FIRST_SISO_MCS_20 20
  96. #define TXP_LAST_SISO_MCS_20 27
  97. #define PHY_CORE_NUM_1 1
  98. #define PHY_CORE_NUM_2 2
  99. #define PHY_CORE_NUM_3 3
  100. #define PHY_CORE_NUM_4 4
  101. #define PHY_CORE_MAX PHY_CORE_NUM_4
  102. #define PHY_CORE_0 0
  103. #define PHY_CORE_1 1
  104. #define PHY_CORE_2 2
  105. #define PHY_CORE_3 3
  106. #define MA_WINDOW_SZ 8
  107. #define PHY_NOISE_SAMPLE_MON 1
  108. #define PHY_NOISE_SAMPLE_EXTERNAL 2
  109. #define PHY_NOISE_WINDOW_SZ 16
  110. #define PHY_NOISE_GLITCH_INIT_MA 10
  111. #define PHY_NOISE_GLITCH_INIT_MA_BADPlCP 10
  112. #define PHY_NOISE_STATE_MON 0x1
  113. #define PHY_NOISE_STATE_EXTERNAL 0x2
  114. #define PHY_NOISE_SAMPLE_LOG_NUM_NPHY 10
  115. #define PHY_NOISE_SAMPLE_LOG_NUM_UCODE 9
  116. #define PHY_NOISE_OFFSETFACT_4322 (-103)
  117. #define PHY_NOISE_MA_WINDOW_SZ 2
  118. #define PHY_RSSI_TABLE_SIZE 64
  119. #define RSSI_ANT_MERGE_MAX 0
  120. #define RSSI_ANT_MERGE_MIN 1
  121. #define RSSI_ANT_MERGE_AVG 2
  122. #define PHY_TSSI_TABLE_SIZE 64
  123. #define APHY_TSSI_TABLE_SIZE 256
  124. #define TX_GAIN_TABLE_LENGTH 64
  125. #define DEFAULT_11A_TXP_IDX 24
  126. #define NUM_TSSI_FRAMES 4
  127. #define NULL_TSSI 0x7f
  128. #define NULL_TSSI_W 0x7f7f
  129. #define PHY_PAPD_EPS_TBL_SIZE_LCNPHY 64
  130. #define LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL 9
  131. #define PHY_TXPWR_MIN 10
  132. #define PHY_TXPWR_MIN_NPHY 8
  133. #define RADIOPWR_OVERRIDE_DEF (-1)
  134. #define PWRTBL_NUM_COEFF 3
  135. #define SPURAVOID_DISABLE 0
  136. #define SPURAVOID_AUTO 1
  137. #define SPURAVOID_FORCEON 2
  138. #define SPURAVOID_FORCEON2 3
  139. #define PHY_SW_TIMER_FAST 15
  140. #define PHY_SW_TIMER_SLOW 60
  141. #define PHY_SW_TIMER_GLACIAL 120
  142. #define PHY_PERICAL_AUTO 0
  143. #define PHY_PERICAL_FULL 1
  144. #define PHY_PERICAL_PARTIAL 2
  145. #define PHY_PERICAL_NODELAY 0
  146. #define PHY_PERICAL_INIT_DELAY 5
  147. #define PHY_PERICAL_ASSOC_DELAY 5
  148. #define PHY_PERICAL_WDOG_DELAY 5
  149. #define MPHASE_TXCAL_NUMCMDS 2
  150. #define PHY_PERICAL_MPHASE_PENDING(pi) \
  151. (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_IDLE)
  152. enum {
  153. MPHASE_CAL_STATE_IDLE = 0,
  154. MPHASE_CAL_STATE_INIT = 1,
  155. MPHASE_CAL_STATE_TXPHASE0,
  156. MPHASE_CAL_STATE_TXPHASE1,
  157. MPHASE_CAL_STATE_TXPHASE2,
  158. MPHASE_CAL_STATE_TXPHASE3,
  159. MPHASE_CAL_STATE_TXPHASE4,
  160. MPHASE_CAL_STATE_TXPHASE5,
  161. MPHASE_CAL_STATE_PAPDCAL,
  162. MPHASE_CAL_STATE_RXCAL,
  163. MPHASE_CAL_STATE_RSSICAL,
  164. MPHASE_CAL_STATE_IDLETSSI
  165. };
  166. enum phy_cal_mode {
  167. CAL_FULL,
  168. CAL_RECAL,
  169. CAL_CURRECAL,
  170. CAL_DIGCAL,
  171. CAL_GCTRL,
  172. CAL_SOFT,
  173. CAL_DIGLO
  174. };
  175. #define RDR_NTIERS 1
  176. #define RDR_TIER_SIZE 64
  177. #define RDR_LIST_SIZE (512/3)
  178. #define RDR_EPOCH_SIZE 40
  179. #define RDR_NANTENNAS 2
  180. #define RDR_NTIER_SIZE RDR_LIST_SIZE
  181. #define RDR_LP_BUFFER_SIZE 64
  182. #define LP_LEN_HIS_SIZE 10
  183. #define STATIC_NUM_RF 32
  184. #define STATIC_NUM_BB 9
  185. #define BB_MULT_MASK 0x0000ffff
  186. #define BB_MULT_VALID_MASK 0x80000000
  187. #define CORDIC_AG 39797
  188. #define CORDIC_NI 18
  189. #define FIXED(X) ((s32)((X) << 16))
  190. #define FLOAT(X) \
  191. (((X) >= 0) ? ((((X) >> 15) + 1) >> 1) : -((((-(X)) >> 15) + 1) >> 1))
  192. #define PHY_CHAIN_TX_DISABLE_TEMP 115
  193. #define PHY_HYSTERESIS_DELTATEMP 5
  194. #define SCAN_INPROG_PHY(pi) \
  195. (mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN))
  196. #define PLT_INPROG_PHY(pi) (mboolisset(pi->measure_hold, PHY_HOLD_FOR_PLT))
  197. #define ASSOC_INPROG_PHY(pi) \
  198. (mboolisset(pi->measure_hold, PHY_HOLD_FOR_ASSOC))
  199. #define SCAN_RM_IN_PROGRESS(pi) \
  200. (mboolisset(pi->measure_hold, PHY_HOLD_FOR_SCAN | PHY_HOLD_FOR_RM))
  201. #define PHY_MUTED(pi) \
  202. (mboolisset(pi->measure_hold, PHY_HOLD_FOR_MUTE))
  203. #define PUB_NOT_ASSOC(pi) \
  204. (mboolisset(pi->measure_hold, PHY_HOLD_FOR_NOT_ASSOC))
  205. struct phy_table_info {
  206. uint table;
  207. int q;
  208. uint max;
  209. };
  210. struct phytbl_info {
  211. const void *tbl_ptr;
  212. u32 tbl_len;
  213. u32 tbl_id;
  214. u32 tbl_offset;
  215. u32 tbl_width;
  216. };
  217. struct interference_info {
  218. u8 curr_home_channel;
  219. u16 crsminpwrthld_40_stored;
  220. u16 crsminpwrthld_20L_stored;
  221. u16 crsminpwrthld_20U_stored;
  222. u16 init_gain_code_core1_stored;
  223. u16 init_gain_code_core2_stored;
  224. u16 init_gain_codeb_core1_stored;
  225. u16 init_gain_codeb_core2_stored;
  226. u16 init_gain_table_stored[4];
  227. u16 clip1_hi_gain_code_core1_stored;
  228. u16 clip1_hi_gain_code_core2_stored;
  229. u16 clip1_hi_gain_codeb_core1_stored;
  230. u16 clip1_hi_gain_codeb_core2_stored;
  231. u16 nb_clip_thresh_core1_stored;
  232. u16 nb_clip_thresh_core2_stored;
  233. u16 init_ofdmlna2gainchange_stored[4];
  234. u16 init_ccklna2gainchange_stored[4];
  235. u16 clip1_lo_gain_code_core1_stored;
  236. u16 clip1_lo_gain_code_core2_stored;
  237. u16 clip1_lo_gain_codeb_core1_stored;
  238. u16 clip1_lo_gain_codeb_core2_stored;
  239. u16 w1_clip_thresh_core1_stored;
  240. u16 w1_clip_thresh_core2_stored;
  241. u16 radio_2056_core1_rssi_gain_stored;
  242. u16 radio_2056_core2_rssi_gain_stored;
  243. u16 energy_drop_timeout_len_stored;
  244. u16 ed_crs40_assertthld0_stored;
  245. u16 ed_crs40_assertthld1_stored;
  246. u16 ed_crs40_deassertthld0_stored;
  247. u16 ed_crs40_deassertthld1_stored;
  248. u16 ed_crs20L_assertthld0_stored;
  249. u16 ed_crs20L_assertthld1_stored;
  250. u16 ed_crs20L_deassertthld0_stored;
  251. u16 ed_crs20L_deassertthld1_stored;
  252. u16 ed_crs20U_assertthld0_stored;
  253. u16 ed_crs20U_assertthld1_stored;
  254. u16 ed_crs20U_deassertthld0_stored;
  255. u16 ed_crs20U_deassertthld1_stored;
  256. u16 badplcp_ma;
  257. u16 badplcp_ma_previous;
  258. u16 badplcp_ma_total;
  259. u16 badplcp_ma_list[MA_WINDOW_SZ];
  260. int badplcp_ma_index;
  261. s16 pre_badplcp_cnt;
  262. s16 bphy_pre_badplcp_cnt;
  263. u16 init_gain_core1;
  264. u16 init_gain_core2;
  265. u16 init_gainb_core1;
  266. u16 init_gainb_core2;
  267. u16 init_gain_rfseq[4];
  268. u16 crsminpwr0;
  269. u16 crsminpwrl0;
  270. u16 crsminpwru0;
  271. s16 crsminpwr_index;
  272. u16 radio_2057_core1_rssi_wb1a_gc_stored;
  273. u16 radio_2057_core2_rssi_wb1a_gc_stored;
  274. u16 radio_2057_core1_rssi_wb1g_gc_stored;
  275. u16 radio_2057_core2_rssi_wb1g_gc_stored;
  276. u16 radio_2057_core1_rssi_wb2_gc_stored;
  277. u16 radio_2057_core2_rssi_wb2_gc_stored;
  278. u16 radio_2057_core1_rssi_nb_gc_stored;
  279. u16 radio_2057_core2_rssi_nb_gc_stored;
  280. };
  281. struct aci_save_gphy {
  282. u16 rc_cal_ovr;
  283. u16 phycrsth1;
  284. u16 phycrsth2;
  285. u16 init_n1p1_gain;
  286. u16 p1_p2_gain;
  287. u16 n1_n2_gain;
  288. u16 n1_p1_gain;
  289. u16 div_search_gain;
  290. u16 div_p1_p2_gain;
  291. u16 div_search_gn_change;
  292. u16 table_7_2;
  293. u16 table_7_3;
  294. u16 cckshbits_gnref;
  295. u16 clip_thresh;
  296. u16 clip2_thresh;
  297. u16 clip3_thresh;
  298. u16 clip_p2_thresh;
  299. u16 clip_pwdn_thresh;
  300. u16 clip_n1p1_thresh;
  301. u16 clip_n1_pwdn_thresh;
  302. u16 bbconfig;
  303. u16 cthr_sthr_shdin;
  304. u16 energy;
  305. u16 clip_p1_p2_thresh;
  306. u16 threshold;
  307. u16 reg15;
  308. u16 reg16;
  309. u16 reg17;
  310. u16 div_srch_idx;
  311. u16 div_srch_p1_p2;
  312. u16 div_srch_gn_back;
  313. u16 ant_dwell;
  314. u16 ant_wr_settle;
  315. };
  316. struct lo_complex_abgphy_info {
  317. s8 i;
  318. s8 q;
  319. };
  320. struct nphy_iq_comp {
  321. s16 a0;
  322. s16 b0;
  323. s16 a1;
  324. s16 b1;
  325. };
  326. struct nphy_txpwrindex {
  327. s8 index;
  328. s8 index_internal;
  329. s8 index_internal_save;
  330. u16 AfectrlOverride;
  331. u16 AfeCtrlDacGain;
  332. u16 rad_gain;
  333. u8 bbmult;
  334. u16 iqcomp_a;
  335. u16 iqcomp_b;
  336. u16 locomp;
  337. };
  338. struct txiqcal_cache {
  339. u16 txcal_coeffs_2G[8];
  340. u16 txcal_radio_regs_2G[8];
  341. struct nphy_iq_comp rxcal_coeffs_2G;
  342. u16 txcal_coeffs_5G[8];
  343. u16 txcal_radio_regs_5G[8];
  344. struct nphy_iq_comp rxcal_coeffs_5G;
  345. };
  346. struct nphy_pwrctrl {
  347. s8 max_pwr_2g;
  348. s8 idle_targ_2g;
  349. s16 pwrdet_2g_a1;
  350. s16 pwrdet_2g_b0;
  351. s16 pwrdet_2g_b1;
  352. s8 max_pwr_5gm;
  353. s8 idle_targ_5gm;
  354. s8 max_pwr_5gh;
  355. s8 max_pwr_5gl;
  356. s16 pwrdet_5gm_a1;
  357. s16 pwrdet_5gm_b0;
  358. s16 pwrdet_5gm_b1;
  359. s16 pwrdet_5gl_a1;
  360. s16 pwrdet_5gl_b0;
  361. s16 pwrdet_5gl_b1;
  362. s16 pwrdet_5gh_a1;
  363. s16 pwrdet_5gh_b0;
  364. s16 pwrdet_5gh_b1;
  365. s8 idle_targ_5gl;
  366. s8 idle_targ_5gh;
  367. s8 idle_tssi_2g;
  368. s8 idle_tssi_5g;
  369. s8 idle_tssi;
  370. s16 a1;
  371. s16 b0;
  372. s16 b1;
  373. };
  374. struct nphy_txgains {
  375. u16 txlpf[2];
  376. u16 txgm[2];
  377. u16 pga[2];
  378. u16 pad[2];
  379. u16 ipa[2];
  380. };
  381. #define PHY_NOISEVAR_BUFSIZE 10
  382. struct nphy_noisevar_buf {
  383. int bufcount;
  384. int tone_id[PHY_NOISEVAR_BUFSIZE];
  385. u32 noise_vars[PHY_NOISEVAR_BUFSIZE];
  386. u32 min_noise_vars[PHY_NOISEVAR_BUFSIZE];
  387. };
  388. struct rssical_cache {
  389. u16 rssical_radio_regs_2G[2];
  390. u16 rssical_phyregs_2G[12];
  391. u16 rssical_radio_regs_5G[2];
  392. u16 rssical_phyregs_5G[12];
  393. };
  394. struct lcnphy_cal_results {
  395. u16 txiqlocal_a;
  396. u16 txiqlocal_b;
  397. u16 txiqlocal_didq;
  398. u8 txiqlocal_ei0;
  399. u8 txiqlocal_eq0;
  400. u8 txiqlocal_fi0;
  401. u8 txiqlocal_fq0;
  402. u16 txiqlocal_bestcoeffs[11];
  403. u16 txiqlocal_bestcoeffs_valid;
  404. u32 papd_eps_tbl[PHY_PAPD_EPS_TBL_SIZE_LCNPHY];
  405. u16 analog_gain_ref;
  406. u16 lut_begin;
  407. u16 lut_end;
  408. u16 lut_step;
  409. u16 rxcompdbm;
  410. u16 papdctrl;
  411. u16 sslpnCalibClkEnCtrl;
  412. u16 rxiqcal_coeff_a0;
  413. u16 rxiqcal_coeff_b0;
  414. };
  415. struct shared_phy {
  416. struct brcms_phy *phy_head;
  417. uint unit;
  418. struct si_pub *sih;
  419. struct phy_shim_info *physhim;
  420. uint corerev;
  421. u32 machwcap;
  422. bool up;
  423. bool clk;
  424. uint now;
  425. u16 vid;
  426. u16 did;
  427. uint chip;
  428. uint chiprev;
  429. uint chippkg;
  430. uint sromrev;
  431. uint boardtype;
  432. uint boardrev;
  433. uint boardvendor;
  434. u32 boardflags;
  435. u32 boardflags2;
  436. uint buscorerev;
  437. uint fast_timer;
  438. uint slow_timer;
  439. uint glacial_timer;
  440. u8 rx_antdiv;
  441. s8 phy_noise_window[MA_WINDOW_SZ];
  442. uint phy_noise_index;
  443. u8 hw_phytxchain;
  444. u8 hw_phyrxchain;
  445. u8 phytxchain;
  446. u8 phyrxchain;
  447. u8 rssi_mode;
  448. bool _rifs_phy;
  449. };
  450. struct brcms_phy_pub {
  451. uint phy_type;
  452. uint phy_rev;
  453. u8 phy_corenum;
  454. u16 radioid;
  455. u8 radiorev;
  456. u8 radiover;
  457. uint coreflags;
  458. uint ana_rev;
  459. bool abgphy_encore;
  460. };
  461. struct phy_func_ptr {
  462. void (*init)(struct brcms_phy *);
  463. void (*calinit)(struct brcms_phy *);
  464. void (*chanset)(struct brcms_phy *, u16 chanspec);
  465. void (*txpwrrecalc)(struct brcms_phy *);
  466. int (*longtrn)(struct brcms_phy *, int);
  467. void (*txiqccget)(struct brcms_phy *, u16 *, u16 *);
  468. void (*txiqccset)(struct brcms_phy *, u16, u16);
  469. u16 (*txloccget)(struct brcms_phy *);
  470. void (*radioloftget)(struct brcms_phy *, u8 *, u8 *, u8 *, u8 *);
  471. void (*carrsuppr)(struct brcms_phy *);
  472. s32 (*rxsigpwr)(struct brcms_phy *, s32);
  473. void (*detach)(struct brcms_phy *);
  474. };
  475. struct brcms_phy {
  476. struct brcms_phy_pub pubpi_ro;
  477. struct shared_phy *sh;
  478. struct phy_func_ptr pi_fptr;
  479. union {
  480. struct brcms_phy_lcnphy *pi_lcnphy;
  481. } u;
  482. bool user_txpwr_at_rfport;
  483. struct d11regs __iomem *regs;
  484. struct brcms_phy *next;
  485. struct brcms_phy_pub pubpi;
  486. bool do_initcal;
  487. bool phytest_on;
  488. bool ofdm_rateset_war;
  489. bool bf_preempt_4306;
  490. u16 radio_chanspec;
  491. u8 antsel_type;
  492. u16 bw;
  493. u8 txpwr_percent;
  494. bool phy_init_por;
  495. bool init_in_progress;
  496. bool initialized;
  497. bool sbtml_gm;
  498. uint refcnt;
  499. bool watchdog_override;
  500. u8 phynoise_state;
  501. uint phynoise_now;
  502. int phynoise_chan_watchdog;
  503. bool phynoise_polling;
  504. bool disable_percal;
  505. u32 measure_hold;
  506. s16 txpa_2g[PWRTBL_NUM_COEFF];
  507. s16 txpa_2g_low_temp[PWRTBL_NUM_COEFF];
  508. s16 txpa_2g_high_temp[PWRTBL_NUM_COEFF];
  509. s16 txpa_5g_low[PWRTBL_NUM_COEFF];
  510. s16 txpa_5g_mid[PWRTBL_NUM_COEFF];
  511. s16 txpa_5g_hi[PWRTBL_NUM_COEFF];
  512. u8 tx_srom_max_2g;
  513. u8 tx_srom_max_5g_low;
  514. u8 tx_srom_max_5g_mid;
  515. u8 tx_srom_max_5g_hi;
  516. u8 tx_srom_max_rate_2g[TXP_NUM_RATES];
  517. u8 tx_srom_max_rate_5g_low[TXP_NUM_RATES];
  518. u8 tx_srom_max_rate_5g_mid[TXP_NUM_RATES];
  519. u8 tx_srom_max_rate_5g_hi[TXP_NUM_RATES];
  520. u8 tx_user_target[TXP_NUM_RATES];
  521. s8 tx_power_offset[TXP_NUM_RATES];
  522. u8 tx_power_target[TXP_NUM_RATES];
  523. struct brcms_phy_srom_fem srom_fem2g;
  524. struct brcms_phy_srom_fem srom_fem5g;
  525. u8 tx_power_max;
  526. u8 tx_power_max_rate_ind;
  527. bool hwpwrctrl;
  528. u8 nphy_txpwrctrl;
  529. s8 nphy_txrx_chain;
  530. bool phy_5g_pwrgain;
  531. u16 phy_wreg;
  532. u16 phy_wreg_limit;
  533. s8 n_preamble_override;
  534. u8 antswitch;
  535. u8 aa2g, aa5g;
  536. s8 idle_tssi[CH_5G_GROUP];
  537. s8 target_idle_tssi;
  538. s8 txpwr_est_Pout;
  539. u8 tx_power_min;
  540. u8 txpwr_limit[TXP_NUM_RATES];
  541. u8 txpwr_env_limit[TXP_NUM_RATES];
  542. u8 adj_pwr_tbl_nphy[ADJ_PWR_TBL_LEN];
  543. bool channel_14_wide_filter;
  544. bool txpwroverride;
  545. bool txpwridx_override_aphy;
  546. s16 radiopwr_override;
  547. u16 hwpwr_txcur;
  548. u8 saved_txpwr_idx;
  549. bool edcrs_threshold_lock;
  550. u32 tr_R_gain_val;
  551. u32 tr_T_gain_val;
  552. s16 ofdm_analog_filt_bw_override;
  553. s16 cck_analog_filt_bw_override;
  554. s16 ofdm_rccal_override;
  555. s16 cck_rccal_override;
  556. u16 extlna_type;
  557. uint interference_mode_crs_time;
  558. u16 crsglitch_prev;
  559. bool interference_mode_crs;
  560. u32 phy_tx_tone_freq;
  561. uint phy_lastcal;
  562. bool phy_forcecal;
  563. bool phy_fixed_noise;
  564. u32 xtalfreq;
  565. u8 pdiv;
  566. s8 carrier_suppr_disable;
  567. bool phy_bphy_evm;
  568. bool phy_bphy_rfcs;
  569. s8 phy_scraminit;
  570. u8 phy_gpiosel;
  571. s16 phy_txcore_disable_temp;
  572. s16 phy_txcore_enable_temp;
  573. s8 phy_tempsense_offset;
  574. bool phy_txcore_heatedup;
  575. u16 radiopwr;
  576. u16 bb_atten;
  577. u16 txctl1;
  578. u16 mintxbias;
  579. u16 mintxmag;
  580. struct lo_complex_abgphy_info gphy_locomp_iq
  581. [STATIC_NUM_RF][STATIC_NUM_BB];
  582. s8 stats_11b_txpower[STATIC_NUM_RF][STATIC_NUM_BB];
  583. u16 gain_table[TX_GAIN_TABLE_LENGTH];
  584. bool loopback_gain;
  585. s16 max_lpback_gain_hdB;
  586. s16 trsw_rx_gain_hdB;
  587. u8 power_vec[8];
  588. u16 rc_cal;
  589. int nrssi_table_delta;
  590. int nrssi_slope_scale;
  591. int nrssi_slope_offset;
  592. int min_rssi;
  593. int max_rssi;
  594. s8 txpwridx;
  595. u8 min_txpower;
  596. u8 a_band_high_disable;
  597. u16 tx_vos;
  598. u16 global_tx_bb_dc_bias_loft;
  599. int rf_max;
  600. int bb_max;
  601. int rf_list_size;
  602. int bb_list_size;
  603. u16 *rf_attn_list;
  604. u16 *bb_attn_list;
  605. u16 padmix_mask;
  606. u16 padmix_reg;
  607. u16 *txmag_list;
  608. uint txmag_len;
  609. bool txmag_enable;
  610. s8 *a_tssi_to_dbm;
  611. s8 *m_tssi_to_dbm;
  612. s8 *l_tssi_to_dbm;
  613. s8 *h_tssi_to_dbm;
  614. u8 *hwtxpwr;
  615. u16 freqtrack_saved_regs[2];
  616. int cur_interference_mode;
  617. bool hwpwrctrl_capable;
  618. bool temppwrctrl_capable;
  619. uint phycal_nslope;
  620. uint phycal_noffset;
  621. uint phycal_mlo;
  622. uint phycal_txpower;
  623. u8 phy_aa2g;
  624. bool nphy_tableloaded;
  625. s8 nphy_rssisel;
  626. u32 nphy_bb_mult_save;
  627. u16 nphy_txiqlocal_bestc[11];
  628. bool nphy_txiqlocal_coeffsvalid;
  629. struct nphy_txpwrindex nphy_txpwrindex[PHY_CORE_NUM_2];
  630. struct nphy_pwrctrl nphy_pwrctrl_info[PHY_CORE_NUM_2];
  631. u16 cck2gpo;
  632. u32 ofdm2gpo;
  633. u32 ofdm5gpo;
  634. u32 ofdm5glpo;
  635. u32 ofdm5ghpo;
  636. u8 bw402gpo;
  637. u8 bw405gpo;
  638. u8 bw405glpo;
  639. u8 bw405ghpo;
  640. u8 cdd2gpo;
  641. u8 cdd5gpo;
  642. u8 cdd5glpo;
  643. u8 cdd5ghpo;
  644. u8 stbc2gpo;
  645. u8 stbc5gpo;
  646. u8 stbc5glpo;
  647. u8 stbc5ghpo;
  648. u8 bwdup2gpo;
  649. u8 bwdup5gpo;
  650. u8 bwdup5glpo;
  651. u8 bwdup5ghpo;
  652. u16 mcs2gpo[8];
  653. u16 mcs5gpo[8];
  654. u16 mcs5glpo[8];
  655. u16 mcs5ghpo[8];
  656. u32 nphy_rxcalparams;
  657. u8 phy_spuravoid;
  658. bool phy_isspuravoid;
  659. u8 phy_pabias;
  660. u8 nphy_papd_skip;
  661. u8 nphy_tssi_slope;
  662. s16 nphy_noise_win[PHY_CORE_MAX][PHY_NOISE_WINDOW_SZ];
  663. u8 nphy_noise_index;
  664. u8 nphy_txpid2g[PHY_CORE_NUM_2];
  665. u8 nphy_txpid5g[PHY_CORE_NUM_2];
  666. u8 nphy_txpid5gl[PHY_CORE_NUM_2];
  667. u8 nphy_txpid5gh[PHY_CORE_NUM_2];
  668. bool nphy_gain_boost;
  669. bool nphy_elna_gain_config;
  670. u16 old_bphy_test;
  671. u16 old_bphy_testcontrol;
  672. bool phyhang_avoid;
  673. bool rssical_nphy;
  674. u8 nphy_perical;
  675. uint nphy_perical_last;
  676. u8 cal_type_override;
  677. u8 mphase_cal_phase_id;
  678. u8 mphase_txcal_cmdidx;
  679. u8 mphase_txcal_numcmds;
  680. u16 mphase_txcal_bestcoeffs[11];
  681. u16 nphy_txiqlocal_chanspec;
  682. u16 nphy_iqcal_chanspec_2G;
  683. u16 nphy_iqcal_chanspec_5G;
  684. u16 nphy_rssical_chanspec_2G;
  685. u16 nphy_rssical_chanspec_5G;
  686. struct wlapi_timer *phycal_timer;
  687. bool use_int_tx_iqlo_cal_nphy;
  688. bool internal_tx_iqlo_cal_tapoff_intpa_nphy;
  689. s16 nphy_lastcal_temp;
  690. struct txiqcal_cache calibration_cache;
  691. struct rssical_cache rssical_cache;
  692. u8 nphy_txpwr_idx[2];
  693. u8 nphy_papd_cal_type;
  694. uint nphy_papd_last_cal;
  695. u16 nphy_papd_tx_gain_at_last_cal[2];
  696. u8 nphy_papd_cal_gain_index[2];
  697. s16 nphy_papd_epsilon_offset[2];
  698. bool nphy_papd_recal_enable;
  699. u32 nphy_papd_recal_counter;
  700. bool nphy_force_papd_cal;
  701. bool nphy_papdcomp;
  702. bool ipa2g_on;
  703. bool ipa5g_on;
  704. u16 classifier_state;
  705. u16 clip_state[2];
  706. uint nphy_deaf_count;
  707. u8 rxiq_samps;
  708. u8 rxiq_antsel;
  709. u16 rfctrlIntc1_save;
  710. u16 rfctrlIntc2_save;
  711. bool first_cal_after_assoc;
  712. u16 tx_rx_cal_radio_saveregs[22];
  713. u16 tx_rx_cal_phy_saveregs[15];
  714. u8 nphy_cal_orig_pwr_idx[2];
  715. u8 nphy_txcal_pwr_idx[2];
  716. u8 nphy_rxcal_pwr_idx[2];
  717. u16 nphy_cal_orig_tx_gain[2];
  718. struct nphy_txgains nphy_cal_target_gain;
  719. u16 nphy_txcal_bbmult;
  720. u16 nphy_gmval;
  721. u16 nphy_saved_bbconf;
  722. bool nphy_gband_spurwar_en;
  723. bool nphy_gband_spurwar2_en;
  724. bool nphy_aband_spurwar_en;
  725. u16 nphy_rccal_value;
  726. u16 nphy_crsminpwr[3];
  727. struct nphy_noisevar_buf nphy_saved_noisevars;
  728. bool nphy_anarxlpf_adjusted;
  729. bool nphy_crsminpwr_adjusted;
  730. bool nphy_noisevars_adjusted;
  731. bool nphy_rxcal_active;
  732. u16 radar_percal_mask;
  733. bool dfs_lp_buffer_nphy;
  734. u16 nphy_fineclockgatecontrol;
  735. s8 rx2tx_biasentry;
  736. u16 crsminpwr0;
  737. u16 crsminpwrl0;
  738. u16 crsminpwru0;
  739. s16 noise_crsminpwr_index;
  740. u16 init_gain_core1;
  741. u16 init_gain_core2;
  742. u16 init_gainb_core1;
  743. u16 init_gainb_core2;
  744. u8 aci_noise_curr_channel;
  745. u16 init_gain_rfseq[4];
  746. bool radio_is_on;
  747. bool nphy_sample_play_lpf_bw_ctl_ovr;
  748. u16 tbl_data_hi;
  749. u16 tbl_data_lo;
  750. u16 tbl_addr;
  751. uint tbl_save_id;
  752. uint tbl_save_offset;
  753. u8 txpwrctrl;
  754. s8 txpwrindex[PHY_CORE_MAX];
  755. u8 phycal_tempdelta;
  756. u32 mcs20_po;
  757. u32 mcs40_po;
  758. struct wiphy *wiphy;
  759. };
  760. struct cs32 {
  761. s32 q;
  762. s32 i;
  763. };
  764. struct radio_regs {
  765. u16 address;
  766. u32 init_a;
  767. u32 init_g;
  768. u8 do_init_a;
  769. u8 do_init_g;
  770. };
  771. struct radio_20xx_regs {
  772. u16 address;
  773. u8 init;
  774. u8 do_init;
  775. };
  776. struct lcnphy_radio_regs {
  777. u16 address;
  778. u8 init_a;
  779. u8 init_g;
  780. u8 do_init_a;
  781. u8 do_init_g;
  782. };
  783. extern u16 read_phy_reg(struct brcms_phy *pi, u16 addr);
  784. extern void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
  785. extern void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
  786. extern void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
  787. extern void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val);
  788. extern u16 read_radio_reg(struct brcms_phy *pi, u16 addr);
  789. extern void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
  790. extern void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
  791. extern void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask,
  792. u16 val);
  793. extern void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask);
  794. extern void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
  795. extern void wlc_phyreg_enter(struct brcms_phy_pub *pih);
  796. extern void wlc_phyreg_exit(struct brcms_phy_pub *pih);
  797. extern void wlc_radioreg_enter(struct brcms_phy_pub *pih);
  798. extern void wlc_radioreg_exit(struct brcms_phy_pub *pih);
  799. extern void wlc_phy_read_table(struct brcms_phy *pi,
  800. const struct phytbl_info *ptbl_info,
  801. u16 tblAddr, u16 tblDataHi,
  802. u16 tblDatalo);
  803. extern void wlc_phy_write_table(struct brcms_phy *pi,
  804. const struct phytbl_info *ptbl_info,
  805. u16 tblAddr, u16 tblDataHi, u16 tblDatalo);
  806. extern void wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id,
  807. uint tbl_offset, u16 tblAddr, u16 tblDataHi,
  808. u16 tblDataLo);
  809. extern void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val);
  810. extern void write_phy_channel_reg(struct brcms_phy *pi, uint val);
  811. extern void wlc_phy_txpower_update_shm(struct brcms_phy *pi);
  812. extern u8 wlc_phy_nbits(s32 value);
  813. extern void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core);
  814. extern uint wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi,
  815. struct radio_20xx_regs *radioregs);
  816. extern uint wlc_phy_init_radio_regs(struct brcms_phy *pi,
  817. const struct radio_regs *radioregs,
  818. u16 core_offset);
  819. extern void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi);
  820. extern void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on);
  821. extern void wlc_phy_papd_decode_epsilon(u32 epsilon, s32 *eps_real,
  822. s32 *eps_imag);
  823. extern void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi);
  824. extern void wlc_phy_cal_perical_mphase_restart(struct brcms_phy *pi);
  825. extern bool wlc_phy_attach_nphy(struct brcms_phy *pi);
  826. extern bool wlc_phy_attach_lcnphy(struct brcms_phy *pi);
  827. extern void wlc_phy_detach_lcnphy(struct brcms_phy *pi);
  828. extern void wlc_phy_init_nphy(struct brcms_phy *pi);
  829. extern void wlc_phy_init_lcnphy(struct brcms_phy *pi);
  830. extern void wlc_phy_cal_init_nphy(struct brcms_phy *pi);
  831. extern void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi);
  832. extern void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi,
  833. u16 chanspec);
  834. extern void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi,
  835. u16 chanspec);
  836. extern void wlc_phy_chanspec_set_fixup_lcnphy(struct brcms_phy *pi,
  837. u16 chanspec);
  838. extern int wlc_phy_channel2freq(uint channel);
  839. extern int wlc_phy_chanspec_freq2bandrange_lpssn(uint);
  840. extern int wlc_phy_chanspec_bandrange_get(struct brcms_phy *, u16 chanspec);
  841. extern void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode);
  842. extern s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi);
  843. extern void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi);
  844. extern void wlc_lcnphy_txpower_recalc_target(struct brcms_phy *pi);
  845. extern void wlc_phy_txpower_recalc_target_lcnphy(struct brcms_phy *pi);
  846. extern void wlc_lcnphy_set_tx_pwr_by_index(struct brcms_phy *pi, int index);
  847. extern void wlc_lcnphy_tx_pu(struct brcms_phy *pi, bool bEnable);
  848. extern void wlc_lcnphy_stop_tx_tone(struct brcms_phy *pi);
  849. extern void wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz,
  850. u16 max_val, bool iqcalmode);
  851. extern void wlc_phy_txpower_sromlimit_get_nphy(struct brcms_phy *pi, uint chan,
  852. u8 *max_pwr, u8 rate_id);
  853. extern void wlc_phy_ofdm_to_mcs_powers_nphy(u8 *power, u8 rate_mcs_start,
  854. u8 rate_mcs_end,
  855. u8 rate_ofdm_start);
  856. extern void wlc_phy_mcs_to_ofdm_powers_nphy(u8 *power,
  857. u8 rate_ofdm_start,
  858. u8 rate_ofdm_end,
  859. u8 rate_mcs_start);
  860. extern u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode);
  861. extern s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode);
  862. extern s8 wlc_lcnphy_tempsense_degree(struct brcms_phy *pi, bool mode);
  863. extern s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode);
  864. extern void wlc_phy_carrier_suppress_lcnphy(struct brcms_phy *pi);
  865. extern void wlc_lcnphy_crsuprs(struct brcms_phy *pi, int channel);
  866. extern void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode);
  867. extern void wlc_2064_vco_cal(struct brcms_phy *pi);
  868. extern void wlc_phy_txpower_recalc_target(struct brcms_phy *pi);
  869. #define LCNPHY_TBL_ID_PAPDCOMPDELTATBL 0x18
  870. #define LCNPHY_TX_POWER_TABLE_SIZE 128
  871. #define LCNPHY_MAX_TX_POWER_INDEX (LCNPHY_TX_POWER_TABLE_SIZE - 1)
  872. #define LCNPHY_TBL_ID_TXPWRCTL 0x07
  873. #define LCNPHY_TX_PWR_CTRL_OFF 0
  874. #define LCNPHY_TX_PWR_CTRL_SW (0x1 << 15)
  875. #define LCNPHY_TX_PWR_CTRL_HW ((0x1 << 15) | \
  876. (0x1 << 14) | \
  877. (0x1 << 13))
  878. #define LCNPHY_TX_PWR_CTRL_TEMPBASED 0xE001
  879. extern void wlc_lcnphy_write_table(struct brcms_phy *pi,
  880. const struct phytbl_info *pti);
  881. extern void wlc_lcnphy_read_table(struct brcms_phy *pi,
  882. struct phytbl_info *pti);
  883. extern void wlc_lcnphy_set_tx_iqcc(struct brcms_phy *pi, u16 a, u16 b);
  884. extern void wlc_lcnphy_set_tx_locc(struct brcms_phy *pi, u16 didq);
  885. extern void wlc_lcnphy_get_tx_iqcc(struct brcms_phy *pi, u16 *a, u16 *b);
  886. extern u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi);
  887. extern void wlc_lcnphy_get_radio_loft(struct brcms_phy *pi, u8 *ei0,
  888. u8 *eq0, u8 *fi0, u8 *fq0);
  889. extern void wlc_lcnphy_calib_modes(struct brcms_phy *pi, uint mode);
  890. extern void wlc_lcnphy_deaf_mode(struct brcms_phy *pi, bool mode);
  891. extern bool wlc_phy_tpc_isenabled_lcnphy(struct brcms_phy *pi);
  892. extern void wlc_lcnphy_tx_pwr_update_npt(struct brcms_phy *pi);
  893. extern s32 wlc_lcnphy_tssi2dbm(s32 tssi, s32 a1, s32 b0, s32 b1);
  894. extern void wlc_lcnphy_get_tssi(struct brcms_phy *pi, s8 *ofdm_pwr,
  895. s8 *cck_pwr);
  896. extern void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi);
  897. extern s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index);
  898. #define NPHY_MAX_HPVGA1_INDEX 10
  899. #define NPHY_DEF_HPVGA1_INDEXLIMIT 7
  900. struct phy_iq_est {
  901. s32 iq_prod;
  902. u32 i_pwr;
  903. u32 q_pwr;
  904. };
  905. extern void wlc_phy_stay_in_carriersearch_nphy(struct brcms_phy *pi,
  906. bool enable);
  907. extern void wlc_nphy_deaf_mode(struct brcms_phy *pi, bool mode);
  908. #define wlc_phy_write_table_nphy(pi, pti) \
  909. wlc_phy_write_table(pi, pti, 0x72, 0x74, 0x73)
  910. #define wlc_phy_read_table_nphy(pi, pti) \
  911. wlc_phy_read_table(pi, pti, 0x72, 0x74, 0x73)
  912. #define wlc_nphy_table_addr(pi, id, off) \
  913. wlc_phy_table_addr((pi), (id), (off), 0x72, 0x74, 0x73)
  914. #define wlc_nphy_table_data_write(pi, w, v) \
  915. wlc_phy_table_data_write((pi), (w), (v))
  916. extern void wlc_phy_table_read_nphy(struct brcms_phy *pi, u32, u32 l, u32 o,
  917. u32 w, void *d);
  918. extern void wlc_phy_table_write_nphy(struct brcms_phy *pi, u32, u32, u32,
  919. u32, const void *);
  920. #define PHY_IPA(pi) \
  921. ((pi->ipa2g_on && CHSPEC_IS2G(pi->radio_chanspec)) || \
  922. (pi->ipa5g_on && CHSPEC_IS5G(pi->radio_chanspec)))
  923. #define BRCMS_PHY_WAR_PR51571(pi) \
  924. if (NREV_LT((pi)->pubpi.phy_rev, 3)) \
  925. (void)R_REG(&(pi)->regs->maccontrol)
  926. extern void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype);
  927. extern void wlc_phy_aci_reset_nphy(struct brcms_phy *pi);
  928. extern void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en);
  929. extern u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint chan);
  930. extern void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on);
  931. extern void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi);
  932. extern void wlc_phy_force_rfseq_nphy(struct brcms_phy *pi, u8 cmd);
  933. extern s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi);
  934. extern u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val);
  935. extern void wlc_phy_rx_iq_est_nphy(struct brcms_phy *pi, struct phy_iq_est *est,
  936. u16 num_samps, u8 wait_time,
  937. u8 wait_for_crs);
  938. extern void wlc_phy_rx_iq_coeffs_nphy(struct brcms_phy *pi, u8 write,
  939. struct nphy_iq_comp *comp);
  940. extern void wlc_phy_aci_and_noise_reduction_nphy(struct brcms_phy *pi);
  941. extern void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih,
  942. u8 rxcore_bitmask);
  943. extern u8 wlc_phy_rxcore_getstate_nphy(struct brcms_phy_pub *pih);
  944. extern void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type);
  945. extern void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi);
  946. extern void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi);
  947. extern void wlc_phy_txpwr_papd_cal_nphy(struct brcms_phy *pi);
  948. extern u16 wlc_phy_txpwr_idx_get_nphy(struct brcms_phy *pi);
  949. extern struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi);
  950. extern int wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi,
  951. struct nphy_txgains target_gain,
  952. bool full, bool m);
  953. extern int wlc_phy_cal_rxiq_nphy(struct brcms_phy *pi,
  954. struct nphy_txgains target_gain,
  955. u8 type, bool d);
  956. extern void wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask,
  957. s8 txpwrindex, bool res);
  958. extern void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core, u8 rssi_type);
  959. extern int wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type,
  960. s32 *rssi_buf, u8 nsamps);
  961. extern void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi);
  962. extern int wlc_phy_aci_scan_nphy(struct brcms_phy *pi);
  963. extern void wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi,
  964. s32 dBm_targetpower, bool debug);
  965. extern int wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val,
  966. u8 mode, u8, bool);
  967. extern void wlc_phy_stopplayback_nphy(struct brcms_phy *pi);
  968. extern void wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf,
  969. u8 num_samps);
  970. extern void wlc_phy_radio205x_vcocal_nphy(struct brcms_phy *pi);
  971. extern int wlc_phy_rssi_compute_nphy(struct brcms_phy *pi,
  972. struct d11rxhdr *rxh);
  973. #define NPHY_TESTPATTERN_BPHY_EVM 0
  974. #define NPHY_TESTPATTERN_BPHY_RFCS 1
  975. extern void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs);
  976. void wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset,
  977. s8 *ofdmoffset);
  978. extern s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi,
  979. u16 chanspec);
  980. extern bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pih);
  981. #endif /* _BRCM_PHY_INT_H_ */