phy_hal.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. /*
  17. * phy_hal.h: functionality exported from the phy to higher layers
  18. */
  19. #ifndef _BRCM_PHY_HAL_H_
  20. #define _BRCM_PHY_HAL_H_
  21. #include <brcmu_utils.h>
  22. #include <brcmu_wifi.h>
  23. #include <phy_shim.h>
  24. #define IDCODE_VER_MASK 0x0000000f
  25. #define IDCODE_VER_SHIFT 0
  26. #define IDCODE_MFG_MASK 0x00000fff
  27. #define IDCODE_MFG_SHIFT 0
  28. #define IDCODE_ID_MASK 0x0ffff000
  29. #define IDCODE_ID_SHIFT 12
  30. #define IDCODE_REV_MASK 0xf0000000
  31. #define IDCODE_REV_SHIFT 28
  32. #define NORADIO_ID 0xe4f5
  33. #define NORADIO_IDCODE 0x4e4f5246
  34. #define BCM2055_ID 0x2055
  35. #define BCM2055_IDCODE 0x02055000
  36. #define BCM2055A0_IDCODE 0x1205517f
  37. #define BCM2056_ID 0x2056
  38. #define BCM2056_IDCODE 0x02056000
  39. #define BCM2056A0_IDCODE 0x1205617f
  40. #define BCM2057_ID 0x2057
  41. #define BCM2057_IDCODE 0x02057000
  42. #define BCM2057A0_IDCODE 0x1205717f
  43. #define BCM2064_ID 0x2064
  44. #define BCM2064_IDCODE 0x02064000
  45. #define BCM2064A0_IDCODE 0x0206417f
  46. #define PHY_TPC_HW_OFF false
  47. #define PHY_TPC_HW_ON true
  48. #define PHY_PERICAL_DRIVERUP 1
  49. #define PHY_PERICAL_WATCHDOG 2
  50. #define PHY_PERICAL_PHYINIT 3
  51. #define PHY_PERICAL_JOIN_BSS 4
  52. #define PHY_PERICAL_START_IBSS 5
  53. #define PHY_PERICAL_UP_BSS 6
  54. #define PHY_PERICAL_CHAN 7
  55. #define PHY_FULLCAL 8
  56. #define PHY_PERICAL_DISABLE 0
  57. #define PHY_PERICAL_SPHASE 1
  58. #define PHY_PERICAL_MPHASE 2
  59. #define PHY_PERICAL_MANUAL 3
  60. #define PHY_HOLD_FOR_ASSOC 1
  61. #define PHY_HOLD_FOR_SCAN 2
  62. #define PHY_HOLD_FOR_RM 4
  63. #define PHY_HOLD_FOR_PLT 8
  64. #define PHY_HOLD_FOR_MUTE 16
  65. #define PHY_HOLD_FOR_NOT_ASSOC 0x20
  66. #define PHY_MUTE_FOR_PREISM 1
  67. #define PHY_MUTE_ALL 0xffffffff
  68. #define PHY_NOISE_FIXED_VAL (-95)
  69. #define PHY_NOISE_FIXED_VAL_NPHY (-92)
  70. #define PHY_NOISE_FIXED_VAL_LCNPHY (-92)
  71. #define PHY_MODE_CAL 0x0002
  72. #define PHY_MODE_NOISEM 0x0004
  73. #define BRCMS_TXPWR_DB_FACTOR 4
  74. /* a large TX Power as an init value to factor out of min() calculations,
  75. * keep low enough to fit in an s8, units are .25 dBm
  76. */
  77. #define BRCMS_TXPWR_MAX (127) /* ~32 dBm = 1,500 mW */
  78. #define BRCMS_NUM_RATES_CCK 4
  79. #define BRCMS_NUM_RATES_OFDM 8
  80. #define BRCMS_NUM_RATES_MCS_1_STREAM 8
  81. #define BRCMS_NUM_RATES_MCS_2_STREAM 8
  82. #define BRCMS_NUM_RATES_MCS_3_STREAM 8
  83. #define BRCMS_NUM_RATES_MCS_4_STREAM 8
  84. #define BRCMS_RSSI_INVALID 0 /* invalid RSSI value */
  85. struct d11regs;
  86. struct phy_shim_info;
  87. struct txpwr_limits {
  88. u8 cck[BRCMS_NUM_RATES_CCK];
  89. u8 ofdm[BRCMS_NUM_RATES_OFDM];
  90. u8 ofdm_cdd[BRCMS_NUM_RATES_OFDM];
  91. u8 ofdm_40_siso[BRCMS_NUM_RATES_OFDM];
  92. u8 ofdm_40_cdd[BRCMS_NUM_RATES_OFDM];
  93. u8 mcs_20_siso[BRCMS_NUM_RATES_MCS_1_STREAM];
  94. u8 mcs_20_cdd[BRCMS_NUM_RATES_MCS_1_STREAM];
  95. u8 mcs_20_stbc[BRCMS_NUM_RATES_MCS_1_STREAM];
  96. u8 mcs_20_mimo[BRCMS_NUM_RATES_MCS_2_STREAM];
  97. u8 mcs_40_siso[BRCMS_NUM_RATES_MCS_1_STREAM];
  98. u8 mcs_40_cdd[BRCMS_NUM_RATES_MCS_1_STREAM];
  99. u8 mcs_40_stbc[BRCMS_NUM_RATES_MCS_1_STREAM];
  100. u8 mcs_40_mimo[BRCMS_NUM_RATES_MCS_2_STREAM];
  101. u8 mcs32;
  102. };
  103. struct tx_power {
  104. u32 flags;
  105. u16 chanspec; /* txpwr report for this channel */
  106. u16 local_chanspec; /* channel on which we are associated */
  107. u8 local_max; /* local max according to the AP */
  108. u8 local_constraint; /* local constraint according to the AP */
  109. s8 antgain[2]; /* Ant gain for each band - from SROM */
  110. u8 rf_cores; /* count of RF Cores being reported */
  111. u8 est_Pout[4]; /* Latest tx power out estimate per RF chain */
  112. u8 est_Pout_act[4]; /* Latest tx power out estimate per RF chain
  113. * without adjustment */
  114. u8 est_Pout_cck; /* Latest CCK tx power out estimate */
  115. u8 tx_power_max[4]; /* Maximum target power among all rates */
  116. /* Index of the rate with the max target power */
  117. u8 tx_power_max_rate_ind[4];
  118. /* User limit */
  119. u8 user_limit[WL_TX_POWER_RATES];
  120. /* Regulatory power limit */
  121. u8 reg_limit[WL_TX_POWER_RATES];
  122. /* Max power board can support (SROM) */
  123. u8 board_limit[WL_TX_POWER_RATES];
  124. /* Latest target power */
  125. u8 target[WL_TX_POWER_RATES];
  126. };
  127. struct tx_inst_power {
  128. u8 txpwr_est_Pout[2]; /* Latest estimate for 2.4 and 5 Ghz */
  129. u8 txpwr_est_Pout_gofdm; /* Pwr estimate for 2.4 OFDM */
  130. };
  131. struct brcms_chanvec {
  132. u8 vec[MAXCHANNEL / NBBY];
  133. };
  134. struct shared_phy_params {
  135. struct si_pub *sih;
  136. struct phy_shim_info *physhim;
  137. uint unit;
  138. uint corerev;
  139. u16 vid;
  140. u16 did;
  141. uint chip;
  142. uint chiprev;
  143. uint chippkg;
  144. uint sromrev;
  145. uint boardtype;
  146. uint boardrev;
  147. u32 boardflags;
  148. u32 boardflags2;
  149. };
  150. struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp);
  151. struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh,
  152. struct bcma_device *d11core, int bandtype,
  153. struct wiphy *wiphy);
  154. void wlc_phy_detach(struct brcms_phy_pub *ppi);
  155. bool wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype,
  156. u16 *phyrev, u16 *radioid, u16 *radiover);
  157. bool wlc_phy_get_encore(struct brcms_phy_pub *pih);
  158. u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih);
  159. void wlc_phy_hw_clk_state_upd(struct brcms_phy_pub *ppi, bool newstate);
  160. void wlc_phy_hw_state_upd(struct brcms_phy_pub *ppi, bool newstate);
  161. void wlc_phy_init(struct brcms_phy_pub *ppi, u16 chanspec);
  162. void wlc_phy_watchdog(struct brcms_phy_pub *ppi);
  163. int wlc_phy_down(struct brcms_phy_pub *ppi);
  164. u32 wlc_phy_clk_bwbits(struct brcms_phy_pub *pih);
  165. void wlc_phy_cal_init(struct brcms_phy_pub *ppi);
  166. void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init);
  167. void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, u16 chanspec);
  168. u16 wlc_phy_chanspec_get(struct brcms_phy_pub *ppi);
  169. void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, u16 newch);
  170. u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi);
  171. void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw);
  172. int wlc_phy_rssi_compute(struct brcms_phy_pub *pih, struct d11rxhdr *rxh);
  173. void wlc_phy_por_inform(struct brcms_phy_pub *ppi);
  174. void wlc_phy_noise_sample_intr(struct brcms_phy_pub *ppi);
  175. bool wlc_phy_bist_check_phy(struct brcms_phy_pub *ppi);
  176. void wlc_phy_set_deaf(struct brcms_phy_pub *ppi, bool user_flag);
  177. void wlc_phy_switch_radio(struct brcms_phy_pub *ppi, bool on);
  178. void wlc_phy_anacore(struct brcms_phy_pub *ppi, bool on);
  179. void wlc_phy_BSSinit(struct brcms_phy_pub *ppi, bool bonlyap, int rssi);
  180. void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi,
  181. bool wide_filter);
  182. void wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band,
  183. struct brcms_chanvec *channels);
  184. u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band);
  185. void wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint chan, u8 *_min_,
  186. u8 *_max_, int rate);
  187. void wlc_phy_txpower_sromlimit_max_get(struct brcms_phy_pub *ppi, uint chan,
  188. u8 *_max_, u8 *_min_);
  189. void wlc_phy_txpower_boardlimit_band(struct brcms_phy_pub *ppi, uint band,
  190. s32 *, s32 *, u32 *);
  191. void wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi, struct txpwr_limits *,
  192. u16 chanspec);
  193. int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm, bool *override);
  194. int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, bool override);
  195. void wlc_phy_txpower_target_set(struct brcms_phy_pub *ppi,
  196. struct txpwr_limits *);
  197. bool wlc_phy_txpower_hw_ctrl_get(struct brcms_phy_pub *ppi);
  198. void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi, bool hwpwrctrl);
  199. u8 wlc_phy_txpower_get_target_min(struct brcms_phy_pub *ppi);
  200. u8 wlc_phy_txpower_get_target_max(struct brcms_phy_pub *ppi);
  201. bool wlc_phy_txpower_ipa_ison(struct brcms_phy_pub *pih);
  202. void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain);
  203. void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain);
  204. void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain, u8 *rxchain);
  205. u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih);
  206. s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih, u16 chanspec);
  207. void wlc_phy_ldpc_override_set(struct brcms_phy_pub *ppi, bool val);
  208. void wlc_phy_cal_perical(struct brcms_phy_pub *ppi, u8 reason);
  209. void wlc_phy_noise_sample_request_external(struct brcms_phy_pub *ppi);
  210. void wlc_phy_edcrs_lock(struct brcms_phy_pub *pih, bool lock);
  211. void wlc_phy_cal_papd_recal(struct brcms_phy_pub *ppi);
  212. void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val);
  213. void wlc_phy_clear_tssi(struct brcms_phy_pub *ppi);
  214. void wlc_phy_hold_upd(struct brcms_phy_pub *ppi, u32 id, bool val);
  215. void wlc_phy_mute_upd(struct brcms_phy_pub *ppi, bool val, u32 flags);
  216. void wlc_phy_antsel_type_set(struct brcms_phy_pub *ppi, u8 antsel_type);
  217. void wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi,
  218. struct tx_power *power, uint channel);
  219. void wlc_phy_initcal_enable(struct brcms_phy_pub *pih, bool initcal);
  220. bool wlc_phy_test_ison(struct brcms_phy_pub *ppi);
  221. void wlc_phy_txpwr_percent_set(struct brcms_phy_pub *ppi, u8 txpwr_percent);
  222. void wlc_phy_ofdm_rateset_war(struct brcms_phy_pub *pih, bool war);
  223. void wlc_phy_bf_preempt_enable(struct brcms_phy_pub *pih, bool bf_preempt);
  224. void wlc_phy_machwcap_set(struct brcms_phy_pub *ppi, u32 machwcap);
  225. void wlc_phy_runbist_config(struct brcms_phy_pub *ppi, bool start_end);
  226. void wlc_phy_freqtrack_start(struct brcms_phy_pub *ppi);
  227. void wlc_phy_freqtrack_end(struct brcms_phy_pub *ppi);
  228. const u8 *wlc_phy_get_ofdm_rate_lookup(void);
  229. s8 wlc_phy_get_tx_power_offset_by_mcs(struct brcms_phy_pub *ppi,
  230. u8 mcs_offset);
  231. s8 wlc_phy_get_tx_power_offset(struct brcms_phy_pub *ppi, u8 tbl_offset);
  232. #endif /* _BRCM_PHY_HAL_H_ */