phy_int.h 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162
  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. u32 boardflags;
  434. u32 boardflags2;
  435. uint fast_timer;
  436. uint slow_timer;
  437. uint glacial_timer;
  438. u8 rx_antdiv;
  439. s8 phy_noise_window[MA_WINDOW_SZ];
  440. uint phy_noise_index;
  441. u8 hw_phytxchain;
  442. u8 hw_phyrxchain;
  443. u8 phytxchain;
  444. u8 phyrxchain;
  445. u8 rssi_mode;
  446. bool _rifs_phy;
  447. };
  448. struct brcms_phy_pub {
  449. uint phy_type;
  450. uint phy_rev;
  451. u8 phy_corenum;
  452. u16 radioid;
  453. u8 radiorev;
  454. u8 radiover;
  455. uint coreflags;
  456. uint ana_rev;
  457. bool abgphy_encore;
  458. };
  459. struct phy_func_ptr {
  460. void (*init)(struct brcms_phy *);
  461. void (*calinit)(struct brcms_phy *);
  462. void (*chanset)(struct brcms_phy *, u16 chanspec);
  463. void (*txpwrrecalc)(struct brcms_phy *);
  464. int (*longtrn)(struct brcms_phy *, int);
  465. void (*txiqccget)(struct brcms_phy *, u16 *, u16 *);
  466. void (*txiqccset)(struct brcms_phy *, u16, u16);
  467. u16 (*txloccget)(struct brcms_phy *);
  468. void (*radioloftget)(struct brcms_phy *, u8 *, u8 *, u8 *, u8 *);
  469. void (*carrsuppr)(struct brcms_phy *);
  470. s32 (*rxsigpwr)(struct brcms_phy *, s32);
  471. void (*detach)(struct brcms_phy *);
  472. };
  473. struct brcms_phy {
  474. struct brcms_phy_pub pubpi_ro;
  475. struct shared_phy *sh;
  476. struct phy_func_ptr pi_fptr;
  477. union {
  478. struct brcms_phy_lcnphy *pi_lcnphy;
  479. } u;
  480. bool user_txpwr_at_rfport;
  481. struct bcma_device *d11core;
  482. struct brcms_phy *next;
  483. struct brcms_phy_pub pubpi;
  484. bool do_initcal;
  485. bool phytest_on;
  486. bool ofdm_rateset_war;
  487. bool bf_preempt_4306;
  488. u16 radio_chanspec;
  489. u8 antsel_type;
  490. u16 bw;
  491. u8 txpwr_percent;
  492. bool phy_init_por;
  493. bool init_in_progress;
  494. bool initialized;
  495. bool sbtml_gm;
  496. uint refcnt;
  497. bool watchdog_override;
  498. u8 phynoise_state;
  499. uint phynoise_now;
  500. int phynoise_chan_watchdog;
  501. bool phynoise_polling;
  502. bool disable_percal;
  503. u32 measure_hold;
  504. s16 txpa_2g[PWRTBL_NUM_COEFF];
  505. s16 txpa_2g_low_temp[PWRTBL_NUM_COEFF];
  506. s16 txpa_2g_high_temp[PWRTBL_NUM_COEFF];
  507. s16 txpa_5g_low[PWRTBL_NUM_COEFF];
  508. s16 txpa_5g_mid[PWRTBL_NUM_COEFF];
  509. s16 txpa_5g_hi[PWRTBL_NUM_COEFF];
  510. u8 tx_srom_max_2g;
  511. u8 tx_srom_max_5g_low;
  512. u8 tx_srom_max_5g_mid;
  513. u8 tx_srom_max_5g_hi;
  514. u8 tx_srom_max_rate_2g[TXP_NUM_RATES];
  515. u8 tx_srom_max_rate_5g_low[TXP_NUM_RATES];
  516. u8 tx_srom_max_rate_5g_mid[TXP_NUM_RATES];
  517. u8 tx_srom_max_rate_5g_hi[TXP_NUM_RATES];
  518. u8 tx_user_target[TXP_NUM_RATES];
  519. s8 tx_power_offset[TXP_NUM_RATES];
  520. u8 tx_power_target[TXP_NUM_RATES];
  521. struct brcms_phy_srom_fem srom_fem2g;
  522. struct brcms_phy_srom_fem srom_fem5g;
  523. u8 tx_power_max;
  524. u8 tx_power_max_rate_ind;
  525. bool hwpwrctrl;
  526. u8 nphy_txpwrctrl;
  527. s8 nphy_txrx_chain;
  528. bool phy_5g_pwrgain;
  529. u16 phy_wreg;
  530. u16 phy_wreg_limit;
  531. s8 n_preamble_override;
  532. u8 antswitch;
  533. u8 aa2g, aa5g;
  534. s8 idle_tssi[CH_5G_GROUP];
  535. s8 target_idle_tssi;
  536. s8 txpwr_est_Pout;
  537. u8 tx_power_min;
  538. u8 txpwr_limit[TXP_NUM_RATES];
  539. u8 txpwr_env_limit[TXP_NUM_RATES];
  540. u8 adj_pwr_tbl_nphy[ADJ_PWR_TBL_LEN];
  541. bool channel_14_wide_filter;
  542. bool txpwroverride;
  543. bool txpwridx_override_aphy;
  544. s16 radiopwr_override;
  545. u16 hwpwr_txcur;
  546. u8 saved_txpwr_idx;
  547. bool edcrs_threshold_lock;
  548. u32 tr_R_gain_val;
  549. u32 tr_T_gain_val;
  550. s16 ofdm_analog_filt_bw_override;
  551. s16 cck_analog_filt_bw_override;
  552. s16 ofdm_rccal_override;
  553. s16 cck_rccal_override;
  554. u16 extlna_type;
  555. uint interference_mode_crs_time;
  556. u16 crsglitch_prev;
  557. bool interference_mode_crs;
  558. u32 phy_tx_tone_freq;
  559. uint phy_lastcal;
  560. bool phy_forcecal;
  561. bool phy_fixed_noise;
  562. u32 xtalfreq;
  563. u8 pdiv;
  564. s8 carrier_suppr_disable;
  565. bool phy_bphy_evm;
  566. bool phy_bphy_rfcs;
  567. s8 phy_scraminit;
  568. u8 phy_gpiosel;
  569. s16 phy_txcore_disable_temp;
  570. s16 phy_txcore_enable_temp;
  571. s8 phy_tempsense_offset;
  572. bool phy_txcore_heatedup;
  573. u16 radiopwr;
  574. u16 bb_atten;
  575. u16 txctl1;
  576. u16 mintxbias;
  577. u16 mintxmag;
  578. struct lo_complex_abgphy_info gphy_locomp_iq
  579. [STATIC_NUM_RF][STATIC_NUM_BB];
  580. s8 stats_11b_txpower[STATIC_NUM_RF][STATIC_NUM_BB];
  581. u16 gain_table[TX_GAIN_TABLE_LENGTH];
  582. bool loopback_gain;
  583. s16 max_lpback_gain_hdB;
  584. s16 trsw_rx_gain_hdB;
  585. u8 power_vec[8];
  586. u16 rc_cal;
  587. int nrssi_table_delta;
  588. int nrssi_slope_scale;
  589. int nrssi_slope_offset;
  590. int min_rssi;
  591. int max_rssi;
  592. s8 txpwridx;
  593. u8 min_txpower;
  594. u8 a_band_high_disable;
  595. u16 tx_vos;
  596. u16 global_tx_bb_dc_bias_loft;
  597. int rf_max;
  598. int bb_max;
  599. int rf_list_size;
  600. int bb_list_size;
  601. u16 *rf_attn_list;
  602. u16 *bb_attn_list;
  603. u16 padmix_mask;
  604. u16 padmix_reg;
  605. u16 *txmag_list;
  606. uint txmag_len;
  607. bool txmag_enable;
  608. s8 *a_tssi_to_dbm;
  609. s8 *m_tssi_to_dbm;
  610. s8 *l_tssi_to_dbm;
  611. s8 *h_tssi_to_dbm;
  612. u8 *hwtxpwr;
  613. u16 freqtrack_saved_regs[2];
  614. int cur_interference_mode;
  615. bool hwpwrctrl_capable;
  616. bool temppwrctrl_capable;
  617. uint phycal_nslope;
  618. uint phycal_noffset;
  619. uint phycal_mlo;
  620. uint phycal_txpower;
  621. u8 phy_aa2g;
  622. bool nphy_tableloaded;
  623. s8 nphy_rssisel;
  624. u32 nphy_bb_mult_save;
  625. u16 nphy_txiqlocal_bestc[11];
  626. bool nphy_txiqlocal_coeffsvalid;
  627. struct nphy_txpwrindex nphy_txpwrindex[PHY_CORE_NUM_2];
  628. struct nphy_pwrctrl nphy_pwrctrl_info[PHY_CORE_NUM_2];
  629. u16 cck2gpo;
  630. u32 ofdm2gpo;
  631. u32 ofdm5gpo;
  632. u32 ofdm5glpo;
  633. u32 ofdm5ghpo;
  634. u8 bw402gpo;
  635. u8 bw405gpo;
  636. u8 bw405glpo;
  637. u8 bw405ghpo;
  638. u8 cdd2gpo;
  639. u8 cdd5gpo;
  640. u8 cdd5glpo;
  641. u8 cdd5ghpo;
  642. u8 stbc2gpo;
  643. u8 stbc5gpo;
  644. u8 stbc5glpo;
  645. u8 stbc5ghpo;
  646. u8 bwdup2gpo;
  647. u8 bwdup5gpo;
  648. u8 bwdup5glpo;
  649. u8 bwdup5ghpo;
  650. u16 mcs2gpo[8];
  651. u16 mcs5gpo[8];
  652. u16 mcs5glpo[8];
  653. u16 mcs5ghpo[8];
  654. u32 nphy_rxcalparams;
  655. u8 phy_spuravoid;
  656. bool phy_isspuravoid;
  657. u8 phy_pabias;
  658. u8 nphy_papd_skip;
  659. u8 nphy_tssi_slope;
  660. s16 nphy_noise_win[PHY_CORE_MAX][PHY_NOISE_WINDOW_SZ];
  661. u8 nphy_noise_index;
  662. bool nphy_gain_boost;
  663. bool nphy_elna_gain_config;
  664. u16 old_bphy_test;
  665. u16 old_bphy_testcontrol;
  666. bool phyhang_avoid;
  667. bool rssical_nphy;
  668. u8 nphy_perical;
  669. uint nphy_perical_last;
  670. u8 cal_type_override;
  671. u8 mphase_cal_phase_id;
  672. u8 mphase_txcal_cmdidx;
  673. u8 mphase_txcal_numcmds;
  674. u16 mphase_txcal_bestcoeffs[11];
  675. u16 nphy_txiqlocal_chanspec;
  676. u16 nphy_iqcal_chanspec_2G;
  677. u16 nphy_iqcal_chanspec_5G;
  678. u16 nphy_rssical_chanspec_2G;
  679. u16 nphy_rssical_chanspec_5G;
  680. struct wlapi_timer *phycal_timer;
  681. bool use_int_tx_iqlo_cal_nphy;
  682. bool internal_tx_iqlo_cal_tapoff_intpa_nphy;
  683. s16 nphy_lastcal_temp;
  684. struct txiqcal_cache calibration_cache;
  685. struct rssical_cache rssical_cache;
  686. u8 nphy_txpwr_idx[2];
  687. u8 nphy_papd_cal_type;
  688. uint nphy_papd_last_cal;
  689. u16 nphy_papd_tx_gain_at_last_cal[2];
  690. u8 nphy_papd_cal_gain_index[2];
  691. s16 nphy_papd_epsilon_offset[2];
  692. bool nphy_papd_recal_enable;
  693. u32 nphy_papd_recal_counter;
  694. bool nphy_force_papd_cal;
  695. bool nphy_papdcomp;
  696. bool ipa2g_on;
  697. bool ipa5g_on;
  698. u16 classifier_state;
  699. u16 clip_state[2];
  700. uint nphy_deaf_count;
  701. u8 rxiq_samps;
  702. u8 rxiq_antsel;
  703. u16 rfctrlIntc1_save;
  704. u16 rfctrlIntc2_save;
  705. bool first_cal_after_assoc;
  706. u16 tx_rx_cal_radio_saveregs[22];
  707. u16 tx_rx_cal_phy_saveregs[15];
  708. u8 nphy_cal_orig_pwr_idx[2];
  709. u8 nphy_txcal_pwr_idx[2];
  710. u8 nphy_rxcal_pwr_idx[2];
  711. u16 nphy_cal_orig_tx_gain[2];
  712. struct nphy_txgains nphy_cal_target_gain;
  713. u16 nphy_txcal_bbmult;
  714. u16 nphy_gmval;
  715. u16 nphy_saved_bbconf;
  716. bool nphy_gband_spurwar_en;
  717. bool nphy_gband_spurwar2_en;
  718. bool nphy_aband_spurwar_en;
  719. u16 nphy_rccal_value;
  720. u16 nphy_crsminpwr[3];
  721. struct nphy_noisevar_buf nphy_saved_noisevars;
  722. bool nphy_anarxlpf_adjusted;
  723. bool nphy_crsminpwr_adjusted;
  724. bool nphy_noisevars_adjusted;
  725. bool nphy_rxcal_active;
  726. u16 radar_percal_mask;
  727. bool dfs_lp_buffer_nphy;
  728. u16 nphy_fineclockgatecontrol;
  729. s8 rx2tx_biasentry;
  730. u16 crsminpwr0;
  731. u16 crsminpwrl0;
  732. u16 crsminpwru0;
  733. s16 noise_crsminpwr_index;
  734. u16 init_gain_core1;
  735. u16 init_gain_core2;
  736. u16 init_gainb_core1;
  737. u16 init_gainb_core2;
  738. u8 aci_noise_curr_channel;
  739. u16 init_gain_rfseq[4];
  740. bool radio_is_on;
  741. bool nphy_sample_play_lpf_bw_ctl_ovr;
  742. u16 tbl_data_hi;
  743. u16 tbl_data_lo;
  744. u16 tbl_addr;
  745. uint tbl_save_id;
  746. uint tbl_save_offset;
  747. u8 txpwrctrl;
  748. s8 txpwrindex[PHY_CORE_MAX];
  749. u8 phycal_tempdelta;
  750. u32 mcs20_po;
  751. u32 mcs40_po;
  752. struct wiphy *wiphy;
  753. };
  754. struct cs32 {
  755. s32 q;
  756. s32 i;
  757. };
  758. struct radio_regs {
  759. u16 address;
  760. u32 init_a;
  761. u32 init_g;
  762. u8 do_init_a;
  763. u8 do_init_g;
  764. };
  765. struct radio_20xx_regs {
  766. u16 address;
  767. u8 init;
  768. u8 do_init;
  769. };
  770. struct lcnphy_radio_regs {
  771. u16 address;
  772. u8 init_a;
  773. u8 init_g;
  774. u8 do_init_a;
  775. u8 do_init_g;
  776. };
  777. extern u16 read_phy_reg(struct brcms_phy *pi, u16 addr);
  778. extern void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
  779. extern void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
  780. extern void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
  781. extern void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val);
  782. extern u16 read_radio_reg(struct brcms_phy *pi, u16 addr);
  783. extern void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
  784. extern void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
  785. extern void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask,
  786. u16 val);
  787. extern void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask);
  788. extern void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val);
  789. extern void wlc_phyreg_enter(struct brcms_phy_pub *pih);
  790. extern void wlc_phyreg_exit(struct brcms_phy_pub *pih);
  791. extern void wlc_radioreg_enter(struct brcms_phy_pub *pih);
  792. extern void wlc_radioreg_exit(struct brcms_phy_pub *pih);
  793. extern void wlc_phy_read_table(struct brcms_phy *pi,
  794. const struct phytbl_info *ptbl_info,
  795. u16 tblAddr, u16 tblDataHi,
  796. u16 tblDatalo);
  797. extern void wlc_phy_write_table(struct brcms_phy *pi,
  798. const struct phytbl_info *ptbl_info,
  799. u16 tblAddr, u16 tblDataHi, u16 tblDatalo);
  800. extern void wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id,
  801. uint tbl_offset, u16 tblAddr, u16 tblDataHi,
  802. u16 tblDataLo);
  803. extern void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val);
  804. extern void write_phy_channel_reg(struct brcms_phy *pi, uint val);
  805. extern void wlc_phy_txpower_update_shm(struct brcms_phy *pi);
  806. extern u8 wlc_phy_nbits(s32 value);
  807. extern void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core);
  808. extern uint wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi,
  809. struct radio_20xx_regs *radioregs);
  810. extern uint wlc_phy_init_radio_regs(struct brcms_phy *pi,
  811. const struct radio_regs *radioregs,
  812. u16 core_offset);
  813. extern void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi);
  814. extern void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on);
  815. extern void wlc_phy_papd_decode_epsilon(u32 epsilon, s32 *eps_real,
  816. s32 *eps_imag);
  817. extern void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi);
  818. extern void wlc_phy_cal_perical_mphase_restart(struct brcms_phy *pi);
  819. extern bool wlc_phy_attach_nphy(struct brcms_phy *pi);
  820. extern bool wlc_phy_attach_lcnphy(struct brcms_phy *pi);
  821. extern void wlc_phy_detach_lcnphy(struct brcms_phy *pi);
  822. extern void wlc_phy_init_nphy(struct brcms_phy *pi);
  823. extern void wlc_phy_init_lcnphy(struct brcms_phy *pi);
  824. extern void wlc_phy_cal_init_nphy(struct brcms_phy *pi);
  825. extern void wlc_phy_cal_init_lcnphy(struct brcms_phy *pi);
  826. extern void wlc_phy_chanspec_set_nphy(struct brcms_phy *pi,
  827. u16 chanspec);
  828. extern void wlc_phy_chanspec_set_lcnphy(struct brcms_phy *pi,
  829. u16 chanspec);
  830. extern void wlc_phy_chanspec_set_fixup_lcnphy(struct brcms_phy *pi,
  831. u16 chanspec);
  832. extern int wlc_phy_channel2freq(uint channel);
  833. extern int wlc_phy_chanspec_freq2bandrange_lpssn(uint);
  834. extern int wlc_phy_chanspec_bandrange_get(struct brcms_phy *, u16 chanspec);
  835. extern void wlc_lcnphy_set_tx_pwr_ctrl(struct brcms_phy *pi, u16 mode);
  836. extern s8 wlc_lcnphy_get_current_tx_pwr_idx(struct brcms_phy *pi);
  837. extern void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi);
  838. extern void wlc_lcnphy_txpower_recalc_target(struct brcms_phy *pi);
  839. extern void wlc_phy_txpower_recalc_target_lcnphy(struct brcms_phy *pi);
  840. extern void wlc_lcnphy_set_tx_pwr_by_index(struct brcms_phy *pi, int index);
  841. extern void wlc_lcnphy_tx_pu(struct brcms_phy *pi, bool bEnable);
  842. extern void wlc_lcnphy_stop_tx_tone(struct brcms_phy *pi);
  843. extern void wlc_lcnphy_start_tx_tone(struct brcms_phy *pi, s32 f_kHz,
  844. u16 max_val, bool iqcalmode);
  845. extern void wlc_phy_txpower_sromlimit_get_nphy(struct brcms_phy *pi, uint chan,
  846. u8 *max_pwr, u8 rate_id);
  847. extern void wlc_phy_ofdm_to_mcs_powers_nphy(u8 *power, u8 rate_mcs_start,
  848. u8 rate_mcs_end,
  849. u8 rate_ofdm_start);
  850. extern void wlc_phy_mcs_to_ofdm_powers_nphy(u8 *power,
  851. u8 rate_ofdm_start,
  852. u8 rate_ofdm_end,
  853. u8 rate_mcs_start);
  854. extern u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode);
  855. extern s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode);
  856. extern s8 wlc_lcnphy_tempsense_degree(struct brcms_phy *pi, bool mode);
  857. extern s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode);
  858. extern void wlc_phy_carrier_suppress_lcnphy(struct brcms_phy *pi);
  859. extern void wlc_lcnphy_crsuprs(struct brcms_phy *pi, int channel);
  860. extern void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode);
  861. extern void wlc_2064_vco_cal(struct brcms_phy *pi);
  862. extern void wlc_phy_txpower_recalc_target(struct brcms_phy *pi);
  863. #define LCNPHY_TBL_ID_PAPDCOMPDELTATBL 0x18
  864. #define LCNPHY_TX_POWER_TABLE_SIZE 128
  865. #define LCNPHY_MAX_TX_POWER_INDEX (LCNPHY_TX_POWER_TABLE_SIZE - 1)
  866. #define LCNPHY_TBL_ID_TXPWRCTL 0x07
  867. #define LCNPHY_TX_PWR_CTRL_OFF 0
  868. #define LCNPHY_TX_PWR_CTRL_SW (0x1 << 15)
  869. #define LCNPHY_TX_PWR_CTRL_HW ((0x1 << 15) | \
  870. (0x1 << 14) | \
  871. (0x1 << 13))
  872. #define LCNPHY_TX_PWR_CTRL_TEMPBASED 0xE001
  873. extern void wlc_lcnphy_write_table(struct brcms_phy *pi,
  874. const struct phytbl_info *pti);
  875. extern void wlc_lcnphy_read_table(struct brcms_phy *pi,
  876. struct phytbl_info *pti);
  877. extern void wlc_lcnphy_set_tx_iqcc(struct brcms_phy *pi, u16 a, u16 b);
  878. extern void wlc_lcnphy_set_tx_locc(struct brcms_phy *pi, u16 didq);
  879. extern void wlc_lcnphy_get_tx_iqcc(struct brcms_phy *pi, u16 *a, u16 *b);
  880. extern u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi);
  881. extern void wlc_lcnphy_get_radio_loft(struct brcms_phy *pi, u8 *ei0,
  882. u8 *eq0, u8 *fi0, u8 *fq0);
  883. extern void wlc_lcnphy_calib_modes(struct brcms_phy *pi, uint mode);
  884. extern void wlc_lcnphy_deaf_mode(struct brcms_phy *pi, bool mode);
  885. extern bool wlc_phy_tpc_isenabled_lcnphy(struct brcms_phy *pi);
  886. extern void wlc_lcnphy_tx_pwr_update_npt(struct brcms_phy *pi);
  887. extern s32 wlc_lcnphy_tssi2dbm(s32 tssi, s32 a1, s32 b0, s32 b1);
  888. extern void wlc_lcnphy_get_tssi(struct brcms_phy *pi, s8 *ofdm_pwr,
  889. s8 *cck_pwr);
  890. extern void wlc_lcnphy_tx_power_adjustment(struct brcms_phy_pub *ppi);
  891. extern s32 wlc_lcnphy_rx_signal_power(struct brcms_phy *pi, s32 gain_index);
  892. #define NPHY_MAX_HPVGA1_INDEX 10
  893. #define NPHY_DEF_HPVGA1_INDEXLIMIT 7
  894. struct phy_iq_est {
  895. s32 iq_prod;
  896. u32 i_pwr;
  897. u32 q_pwr;
  898. };
  899. extern void wlc_phy_stay_in_carriersearch_nphy(struct brcms_phy *pi,
  900. bool enable);
  901. extern void wlc_nphy_deaf_mode(struct brcms_phy *pi, bool mode);
  902. #define wlc_phy_write_table_nphy(pi, pti) \
  903. wlc_phy_write_table(pi, pti, 0x72, 0x74, 0x73)
  904. #define wlc_phy_read_table_nphy(pi, pti) \
  905. wlc_phy_read_table(pi, pti, 0x72, 0x74, 0x73)
  906. #define wlc_nphy_table_addr(pi, id, off) \
  907. wlc_phy_table_addr((pi), (id), (off), 0x72, 0x74, 0x73)
  908. #define wlc_nphy_table_data_write(pi, w, v) \
  909. wlc_phy_table_data_write((pi), (w), (v))
  910. extern void wlc_phy_table_read_nphy(struct brcms_phy *pi, u32, u32 l, u32 o,
  911. u32 w, void *d);
  912. extern void wlc_phy_table_write_nphy(struct brcms_phy *pi, u32, u32, u32,
  913. u32, const void *);
  914. #define PHY_IPA(pi) \
  915. ((pi->ipa2g_on && CHSPEC_IS2G(pi->radio_chanspec)) || \
  916. (pi->ipa5g_on && CHSPEC_IS5G(pi->radio_chanspec)))
  917. #define BRCMS_PHY_WAR_PR51571(pi) \
  918. if (NREV_LT((pi)->pubpi.phy_rev, 3)) \
  919. (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol))
  920. extern void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype);
  921. extern void wlc_phy_aci_reset_nphy(struct brcms_phy *pi);
  922. extern void wlc_phy_pa_override_nphy(struct brcms_phy *pi, bool en);
  923. extern u8 wlc_phy_get_chan_freq_range_nphy(struct brcms_phy *pi, uint chan);
  924. extern void wlc_phy_switch_radio_nphy(struct brcms_phy *pi, bool on);
  925. extern void wlc_phy_stf_chain_upd_nphy(struct brcms_phy *pi);
  926. extern void wlc_phy_force_rfseq_nphy(struct brcms_phy *pi, u8 cmd);
  927. extern s16 wlc_phy_tempsense_nphy(struct brcms_phy *pi);
  928. extern u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val);
  929. extern void wlc_phy_rx_iq_est_nphy(struct brcms_phy *pi, struct phy_iq_est *est,
  930. u16 num_samps, u8 wait_time,
  931. u8 wait_for_crs);
  932. extern void wlc_phy_rx_iq_coeffs_nphy(struct brcms_phy *pi, u8 write,
  933. struct nphy_iq_comp *comp);
  934. extern void wlc_phy_aci_and_noise_reduction_nphy(struct brcms_phy *pi);
  935. extern void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih,
  936. u8 rxcore_bitmask);
  937. extern u8 wlc_phy_rxcore_getstate_nphy(struct brcms_phy_pub *pih);
  938. extern void wlc_phy_txpwrctrl_enable_nphy(struct brcms_phy *pi, u8 ctrl_type);
  939. extern void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi);
  940. extern void wlc_phy_txpwr_apply_nphy(struct brcms_phy *pi);
  941. extern void wlc_phy_txpwr_papd_cal_nphy(struct brcms_phy *pi);
  942. extern u16 wlc_phy_txpwr_idx_get_nphy(struct brcms_phy *pi);
  943. extern struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi);
  944. extern int wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi,
  945. struct nphy_txgains target_gain,
  946. bool full, bool m);
  947. extern int wlc_phy_cal_rxiq_nphy(struct brcms_phy *pi,
  948. struct nphy_txgains target_gain,
  949. u8 type, bool d);
  950. extern void wlc_phy_txpwr_index_nphy(struct brcms_phy *pi, u8 core_mask,
  951. s8 txpwrindex, bool res);
  952. extern void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core, u8 rssi_type);
  953. extern int wlc_phy_poll_rssi_nphy(struct brcms_phy *pi, u8 rssi_type,
  954. s32 *rssi_buf, u8 nsamps);
  955. extern void wlc_phy_rssi_cal_nphy(struct brcms_phy *pi);
  956. extern int wlc_phy_aci_scan_nphy(struct brcms_phy *pi);
  957. extern void wlc_phy_cal_txgainctrl_nphy(struct brcms_phy *pi,
  958. s32 dBm_targetpower, bool debug);
  959. extern int wlc_phy_tx_tone_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val,
  960. u8 mode, u8, bool);
  961. extern void wlc_phy_stopplayback_nphy(struct brcms_phy *pi);
  962. extern void wlc_phy_est_tonepwr_nphy(struct brcms_phy *pi, s32 *qdBm_pwrbuf,
  963. u8 num_samps);
  964. extern void wlc_phy_radio205x_vcocal_nphy(struct brcms_phy *pi);
  965. extern int wlc_phy_rssi_compute_nphy(struct brcms_phy *pi,
  966. struct d11rxhdr *rxh);
  967. #define NPHY_TESTPATTERN_BPHY_EVM 0
  968. #define NPHY_TESTPATTERN_BPHY_RFCS 1
  969. extern void wlc_phy_nphy_tkip_rifs_war(struct brcms_phy *pi, u8 rifs);
  970. void wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset,
  971. s8 *ofdmoffset);
  972. extern s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi,
  973. u16 chanspec);
  974. extern bool wlc_phy_n_txpower_ipa_ison(struct brcms_phy *pih);
  975. #endif /* _BRCM_PHY_INT_H_ */