/drivers/staging/brcm80211/brcmsmac/phy/phy_int.h

https://bitbucket.org/cyanogenmod/android_kernel_asus_tf300t · C Header · 1235 lines · 1027 code · 193 blank · 15 comment · 21 complexity · 0f838433f590c2e72aad6509fe5a41ed MD5 · raw file

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