halbtc8821c1ant.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2016 - 2017 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. *****************************************************************************/
  15. #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1)
  16. #if (RTL8821C_SUPPORT == 1)
  17. /* *******************************************
  18. * The following is for 8821C 1ANT BT Co-exist definition
  19. * ******************************************* */
  20. #define BT_8821C_1ANT_COEX_DBG 0
  21. #define BT_AUTO_REPORT_ONLY_8821C_1ANT 1
  22. #define BT_INFO_8821C_1ANT_B_FTP BIT(7)
  23. #define BT_INFO_8821C_1ANT_B_A2DP BIT(6)
  24. #define BT_INFO_8821C_1ANT_B_HID BIT(5)
  25. #define BT_INFO_8821C_1ANT_B_SCO_BUSY BIT(4)
  26. #define BT_INFO_8821C_1ANT_B_ACL_BUSY BIT(3)
  27. #define BT_INFO_8821C_1ANT_B_INQ_PAGE BIT(2)
  28. #define BT_INFO_8821C_1ANT_B_SCO_ESCO BIT(1)
  29. #define BT_INFO_8821C_1ANT_B_CONNECTION BIT(0)
  30. #define BTC_RSSI_COEX_THRESH_TOL_8821C_1ANT 2
  31. #define BT_8821C_1ANT_WIFI_NOISY_THRESH 30
  32. #define BT_8821C_1ANT_DEFAULT_ISOLATION 15
  33. enum bt_8821c_1ant_signal_state {
  34. BT_8821C_1ANT_GNT_SET_TO_LOW = 0x0,
  35. BT_8821C_1ANT_GNT_SET_TO_HIGH = 0x1,
  36. BT_8821C_1ANT_GNT_SET_BY_HW = 0x2,
  37. BT_8821C_1ANT_GNT_SET_MAX
  38. };
  39. enum bt_8821c_1ant_path_ctrl_owner {
  40. BT_8821C_1ANT_PCO_BTSIDE = 0x0,
  41. BT_8821C_1ANT_PCO_WLSIDE = 0x1,
  42. BT_8821C_1ANT_PCO_MAX
  43. };
  44. enum bt_8821c_1ant_gnt_ctrl_type {
  45. BT_8821C_1ANT_GNT_TYPE_CTRL_BY_PTA = 0x0,
  46. BT_8821C_1ANT_GNT_TYPE_CTRL_BY_SW = 0x1,
  47. BT_8821C_1ANT_GNT_TYPE_MAX
  48. };
  49. enum bt_8821c_1ant_gnt_ctrl_block {
  50. BT_8821C_1ANT_GNT_BLOCK_RFC_BB = 0x0,
  51. BT_8821C_1ANT_GNT_BLOCK_RFC = 0x1,
  52. BT_8821C_1ANT_GNT_BLOCK_BB = 0x2,
  53. BT_8821C_1ANT_GNT_BLOCK_MAX
  54. };
  55. enum bt_8821c_1ant_lte_coex_table_type {
  56. BT_8821C_1ANT_CTT_WL_VS_LTE = 0x0,
  57. BT_8821C_1ANT_CTT_BT_VS_LTE = 0x1,
  58. BT_8821C_1ANT_CTT_MAX
  59. };
  60. enum bt_8821c_1ant_lte_break_table_type {
  61. BT_8821C_1ANT_LBTT_WL_BREAK_LTE = 0x0,
  62. BT_8821C_1ANT_LBTT_BT_BREAK_LTE = 0x1,
  63. BT_8821C_1ANT_LBTT_LTE_BREAK_WL = 0x2,
  64. BT_8821C_1ANT_LBTT_LTE_BREAK_BT = 0x3,
  65. BT_8821C_1ANT_LBTT_MAX
  66. };
  67. enum bt_info_src_8821c_1ant {
  68. BT_8821C_1ANT_INFO_SRC_WIFI_FW = 0x0,
  69. BT_8821C_1ANT_INFO_SRC_BT_RSP = 0x1,
  70. BT_8821C_1ANT_INFO_SRC_BT_ACT = 0x2,
  71. BT_8821C_1ANT_INFO_SRC_MAX
  72. };
  73. enum bt_8821c_1ant_bt_status {
  74. BT_8821C_1ANT_BSTATUS_NCON_IDLE = 0x0,
  75. BT_8821C_1ANT_BSTATUS_CON_IDLE = 0x1,
  76. BT_8821C_1ANT_BSTATUS_INQ_PAGE = 0x2,
  77. BT_8821C_1ANT_BSTATUS_ACL_BUSY = 0x3,
  78. BT_8821C_1ANT_BSTATUS_SCO_BUSY = 0x4,
  79. BT_8821C_1ANT_BSTATUS_ACL_SCO_BUSY = 0x5,
  80. BT_8821C_1ANT_BSTATUS_MAX
  81. };
  82. enum bt_8821c_1ant_wifi_status {
  83. BT_8821C_1ANT_WSTATUS_NCON_IDLE = 0x0,
  84. BT_8821C_1ANT_WSTATUS_NCON_SCAN = 0x1,
  85. BT_8821C_1ANT_WSTATUS_CON_SCAN = 0x2,
  86. BT_8821C_1ANT_WSTATUS_CON_SPECPKT = 0x3,
  87. BT_8821C_1ANT_WSTATUS_CON_IDLE = 0x4,
  88. BT_8821C_1ANT_WSTATUS_CON_BUSY = 0x5,
  89. BT_8821C_1ANT_WSTATUS_MAX
  90. };
  91. enum bt_8821c_1ant_coex_algo {
  92. BT_8821C_1ANT_COEX_UNDEFINED = 0x0,
  93. BT_8821C_1ANT_COEX_SCO = 0x1,
  94. BT_8821C_1ANT_COEX_HID = 0x2,
  95. BT_8821C_1ANT_COEX_A2DP = 0x3,
  96. BT_8821C_1ANT_COEX_A2DP_PANHS = 0x4,
  97. BT_8821C_1ANT_COEX_PAN = 0x5,
  98. BT_8821C_1ANT_COEX_PANHS = 0x6,
  99. BT_8821C_1ANT_COEX_PAN_A2DP = 0x7,
  100. BT_8821C_1ANT_COEX_PAN_HID = 0x8,
  101. BT_8821C_1ANT_COEX_HID_A2DP_PAN = 0x9,
  102. BT_8821C_1ANT_COEX_HID_A2DP = 0xa,
  103. BT_8821C_1ANT_COEX_MAX = 0xb,
  104. };
  105. enum bt_8821c_1ant_ext_ant_switch_type {
  106. BT_8821C_1ANT_USE_DPDT = 0x0,
  107. BT_8821C_1ANT_USE_SPDT = 0x1,
  108. BT_8821C_1ANT_SWITCH_NONE = 0x2,
  109. BT_8821C_1ANT_SWITCH_MAX
  110. };
  111. enum bt_8821c_1ant_ext_ant_switch_ctrl_type {
  112. BT_8821C_1ANT_CTRL_BY_BBSW = 0x0,
  113. BT_8821C_1ANT_CTRL_BY_PTA = 0x1,
  114. BT_8821C_1ANT_CTRL_BY_ANTDIV = 0x2,
  115. BT_8821C_1ANT_CTRL_BY_MAC = 0x3,
  116. BT_8821C_1ANT_CTRL_BY_BT = 0x4,
  117. BT_8821C_1ANT_CTRL_BY_FW = 0x5,
  118. BT_8821C_1ANT_CTRL_MAX
  119. };
  120. enum bt_8821c_1ant_ext_ant_switch_pos_type {
  121. BT_8821C_1ANT_TO_BT = 0x0,
  122. BT_8821C_1ANT_TO_WLG = 0x1,
  123. BT_8821C_1ANT_TO_WLA = 0x2,
  124. BT_8821C_1ANT_TO_NOCARE = 0x3,
  125. BT_8821C_1ANT_TO_MAX
  126. };
  127. enum bt_8821c_1ant_phase {
  128. BT_8821C_1ANT_PHASE_INIT = 0x0,
  129. BT_8821C_1ANT_PHASE_WONLY = 0x1,
  130. BT_8821C_1ANT_PHASE_WOFF = 0x2,
  131. BT_8821C_1ANT_PHASE_2G = 0x3,
  132. BT_8821C_1ANT_PHASE_5G = 0x4,
  133. BT_8821C_1ANT_PHASE_BTMP = 0x5,
  134. BT_8821C_1ANT_PHASE_ANTDET = 0x6,
  135. BT_8821C_1ANT_PHASE_POWERON = 0x7,
  136. BT_8821C_1ANT_PHASE_MCC = 0x8,
  137. BT_8821C_1ANT_PHASE_MAX
  138. };
  139. enum bt_8821c_1ant_scoreboard {
  140. BT_8821C_1ANT_SCBD_ACTIVE = BIT(0),
  141. BT_8821C_1ANT_SCBD_ONOFF = BIT(1),
  142. BT_8821C_1ANT_SCBD_SCAN = BIT(2),
  143. BT_8821C_1ANT_SCBD_UNDERTEST = BIT(3),
  144. BT_8821C_1ANT_SCBD_WLBUSY = BIT(6),
  145. BT_8821C_1ANT_SCBD_BTCQDDR = BIT(10)
  146. };
  147. enum bt_8821c_1ant_RUNREASON {
  148. BT_8821C_1ANT_RSN_2GSCANSTART = 0x0,
  149. BT_8821C_1ANT_RSN_5GSCANSTART = 0x1,
  150. BT_8821C_1ANT_RSN_SCANFINISH = 0x2,
  151. BT_8821C_1ANT_RSN_2GSWITCHBAND = 0x3,
  152. BT_8821C_1ANT_RSN_5GSWITCHBAND = 0x4,
  153. BT_8821C_1ANT_RSN_2GCONSTART = 0x5,
  154. BT_8821C_1ANT_RSN_5GCONSTART = 0x6,
  155. BT_8821C_1ANT_RSN_2GCONFINISH = 0x7,
  156. BT_8821C_1ANT_RSN_5GCONFINISH = 0x8,
  157. BT_8821C_1ANT_RSN_2GMEDIA = 0x9,
  158. BT_8821C_1ANT_RSN_5GMEDIA = 0xa,
  159. BT_8821C_1ANT_RSN_MEDIADISCON = 0xb,
  160. BT_8821C_1ANT_RSN_2GSPECIALPKT = 0xc,
  161. BT_8821C_1ANT_RSN_5GSPECIALPKT = 0xd,
  162. BT_8821C_1ANT_RSN_BTINFO = 0xe,
  163. BT_8821C_1ANT_RSN_PERIODICAL = 0xf,
  164. BT_8821C_1ANT_RSN_PNP = 0x10,
  165. BT_8821C_1ANT_RSN_MAX
  166. };
  167. enum bt_8821c_1ant_WL_LINK_MODE {
  168. BT_8821C_1ANT_WLINK_2G1PORT = 0x0,
  169. BT_8821C_1ANT_WLINK_2GMPORT = 0x1,
  170. BT_8821C_1ANT_WLINK_25GMPORT = 0x2,
  171. BT_8821C_1ANT_WLINK_5G = 0x3,
  172. BT_8821C_1ANT_WLINK_2GGO = 0x4,
  173. BT_8821C_1ANT_WLINK_BTMR = 0x5,
  174. BT_8821C_1ANT_WLINK_MAX
  175. };
  176. struct coex_dm_8821c_1ant {
  177. /* hw setting */
  178. u32 cur_ant_pos_type;
  179. /* fw mechanism */
  180. boolean cur_ignore_wlan_act;
  181. u8 cur_ps_tdma;
  182. u8 ps_tdma_para[5];
  183. boolean cur_ps_tdma_on;
  184. boolean cur_bt_auto_report;
  185. u8 cur_lps;
  186. u8 cur_rpwm;
  187. /* sw mechanism */
  188. boolean cur_low_penalty_ra;
  189. u32 cur_val0x6c0;
  190. u32 cur_val0x6c4;
  191. u32 cur_val0x6c8;
  192. u8 cur_val0x6cc;
  193. /* algorithm related */
  194. u8 cur_algorithm;
  195. u8 bt_status;
  196. u8 wifi_chnl_info[3];
  197. u32 arp_cnt;
  198. u32 cur_ext_ant_switch_status;
  199. u32 setting_tdma;
  200. };
  201. struct coex_sta_8821c_1ant {
  202. boolean bt_disabled;
  203. boolean bt_link_exist;
  204. boolean sco_exist;
  205. boolean a2dp_exist;
  206. boolean hid_exist;
  207. boolean pan_exist;
  208. boolean msft_mr_exist;
  209. u8 num_of_profile;
  210. boolean under_lps;
  211. boolean under_ips;
  212. u32 specific_pkt_period_cnt;
  213. u32 high_priority_tx;
  214. u32 high_priority_rx;
  215. u32 low_priority_tx;
  216. u32 low_priority_rx;
  217. boolean is_hi_pri_rx_overhead;
  218. s8 bt_rssi;
  219. u8 pre_bt_rssi_state;
  220. u8 pre_wifi_rssi_state[4];
  221. u8 bt_info_c2h[BT_8821C_1ANT_INFO_SRC_MAX][10];
  222. u32 bt_info_c2h_cnt[BT_8821C_1ANT_INFO_SRC_MAX];
  223. boolean bt_whck_test;
  224. boolean c2h_bt_inquiry_page;
  225. boolean c2h_bt_remote_name_req;
  226. boolean c2h_bt_page;
  227. boolean wifi_high_pri_task1;
  228. boolean wifi_high_pri_task2;
  229. u8 bt_info_ext;
  230. u8 bt_info_ext2;
  231. u32 pop_event_cnt;
  232. u8 scan_ap_num;
  233. u8 bt_retry_cnt;
  234. u32 crc_ok_cck;
  235. u32 crc_ok_11g;
  236. u32 crc_ok_11n;
  237. u32 crc_ok_11n_vht;
  238. u32 crc_err_cck;
  239. u32 crc_err_11g;
  240. u32 crc_err_11n;
  241. u32 crc_err_11n_vht;
  242. boolean cck_lock;
  243. boolean cck_lock_ever;
  244. boolean cck_lock_warn;
  245. u8 coex_table_type;
  246. boolean force_lps_ctrl;
  247. boolean concurrent_rx_mode_on;
  248. u16 score_board;
  249. u8 isolation_btween_wb; /* 0~ 50 */
  250. u8 a2dp_bit_pool;
  251. u8 cut_version;
  252. boolean acl_busy;
  253. boolean bt_create_connection;
  254. u32 bt_coex_supported_feature;
  255. u32 bt_coex_supported_version;
  256. u8 bt_ble_scan_type;
  257. u32 bt_ble_scan_para[3];
  258. boolean run_time_state;
  259. boolean freeze_coexrun_by_btinfo;
  260. boolean is_A2DP_3M;
  261. boolean voice_over_HOGP;
  262. u8 bt_info;
  263. boolean is_autoslot;
  264. u8 forbidden_slot;
  265. u8 hid_busy_num;
  266. u8 hid_pair_cnt;
  267. u32 cnt_remote_name_req;
  268. u32 cnt_setup_link;
  269. u32 cnt_reinit;
  270. u32 cnt_ign_wlan_act;
  271. u32 cnt_page;
  272. u32 cnt_role_switch;
  273. u16 bt_reg_vendor_ac;
  274. u16 bt_reg_vendor_ae;
  275. boolean is_setup_link;
  276. u8 wl_noisy_level;
  277. u32 gnt_error_cnt;
  278. u8 bt_afh_map[10];
  279. u8 bt_relink_downcount;
  280. boolean is_tdma_btautoslot;
  281. boolean is_tdma_btautoslot_hang;
  282. u8 switch_band_notify_to;
  283. boolean is_rf_state_off;
  284. boolean is_hid_low_pri_tx_overhead;
  285. boolean is_bt_multi_link;
  286. boolean is_bt_a2dp_sink;
  287. boolean is_set_ps_state_fail;
  288. u8 cnt_set_ps_state_fail;
  289. u8 wl_fw_dbg_info[10];
  290. u8 wl_rx_rate;
  291. u8 wl_tx_rate;
  292. u8 wl_rts_rx_rate;
  293. u8 wl_center_channel;
  294. u8 wl_tx_macid;
  295. u8 wl_tx_retry_ratio;
  296. u16 score_board_WB;
  297. boolean is_hid_rcu;
  298. u16 legacy_forbidden_slot;
  299. u16 le_forbidden_slot;
  300. u8 bt_a2dp_vendor_id;
  301. u32 bt_a2dp_device_name;
  302. boolean is_ble_scan_en;
  303. boolean is_bt_opp_exist;
  304. boolean gl_wifi_busy;
  305. u8 connect_ap_period_cnt;
  306. boolean is_bt_reenable;
  307. u8 cnt_bt_reenable;
  308. boolean is_wifi_linkscan_process;
  309. u8 wl_coex_mode;
  310. u8 wl_pnp_wakeup_downcnt;
  311. u32 coex_run_cnt;
  312. };
  313. #define BT_8821C_1ANT_EXT_BAND_SWITCH_USE_DPDT 0
  314. #define BT_8821C_1ANT_EXT_BAND_SWITCH_USE_SPDT 1
  315. struct rfe_type_8821c_1ant {
  316. u8 rfe_module_type;
  317. boolean ext_ant_switch_exist;
  318. /* 0:DPDT, 1:SPDT */
  319. u8 ext_ant_switch_type;
  320. /* iF 0: DPDT_P=0, DPDT_N=1 => BTG to Main, WL_A+G to Aux */
  321. u8 ext_ant_switch_ctrl_polarity;
  322. boolean ext_band_switch_exist;
  323. /* 0:DPDT, 1:SPDT */
  324. u8 ext_band_switch_type;
  325. u8 ext_band_switch_ctrl_polarity;
  326. boolean ant_at_main_port;
  327. /* If TRUE: WLG at BTG, If FALSE: WLG at WLAG */
  328. boolean wlg_locate_at_btg;
  329. /* If diversity on */
  330. boolean ext_ant_switch_diversity;
  331. };
  332. struct wifi_link_info_8821c_1ant {
  333. u8 num_of_active_port;
  334. u32 port_connect_status;
  335. boolean is_all_under_5g;
  336. boolean is_mcc_25g;
  337. boolean is_p2p_connected;
  338. };
  339. /* *******************************************
  340. * The following is interface which will notify coex module.
  341. * ******************************************* */
  342. void ex_halbtc8821c1ant_power_on_setting(struct btc_coexist *btc);
  343. void ex_halbtc8821c1ant_pre_load_firmware(struct btc_coexist *btc);
  344. void ex_halbtc8821c1ant_init_hw_config(struct btc_coexist *btc,
  345. boolean wifi_only);
  346. void ex_halbtc8821c1ant_init_coex_dm(struct btc_coexist *btc);
  347. void ex_halbtc8821c1ant_ips_notify(struct btc_coexist *btc,
  348. u8 type);
  349. void ex_halbtc8821c1ant_lps_notify(struct btc_coexist *btc,
  350. u8 type);
  351. void ex_halbtc8821c1ant_scan_notify(struct btc_coexist *btc,
  352. u8 type);
  353. void ex_halbtc8821c1ant_switchband_notify(struct btc_coexist *btc,
  354. u8 type);
  355. void ex_halbtc8821c1ant_connect_notify(struct btc_coexist *btc,
  356. u8 type);
  357. void ex_halbtc8821c1ant_media_status_notify(struct btc_coexist *btc,
  358. u8 type);
  359. void ex_halbtc8821c1ant_specific_packet_notify(struct btc_coexist *btc,
  360. u8 type);
  361. void ex_halbtc8821c1ant_bt_info_notify(struct btc_coexist *btc,
  362. u8 *tmp_buf, u8 length);
  363. void ex_halbtc8821c1ant_wl_fwdbginfo_notify(struct btc_coexist *btc,
  364. u8 *tmp_buf, u8 length);
  365. void ex_halbtc8821c1ant_rx_rate_change_notify(struct btc_coexist *btc,
  366. BOOLEAN is_data_frame,
  367. u8 btc_rate_id);
  368. void ex_halbtc8821c1ant_tx_rate_change_notify(struct btc_coexist *btc,
  369. u8 tx_rate,
  370. u8 tx_retry_ratio, u8 macid);
  371. void ex_halbtc8821c1ant_rf_status_notify(struct btc_coexist *btc,
  372. u8 type);
  373. void ex_halbtc8821c1ant_halt_notify(struct btc_coexist *btc);
  374. void ex_halbtc8821c1ant_pnp_notify(struct btc_coexist *btc,
  375. u8 pnp_state);
  376. void ex_halbtc8821c1ant_coex_dm_reset(struct btc_coexist *btc);
  377. void ex_halbtc8821c1ant_periodical(struct btc_coexist *btc);
  378. void ex_halbtc8821c1ant_display_simple_coex_info(struct btc_coexist *btc);
  379. void ex_halbtc8821c1ant_display_coex_info(struct btc_coexist *btc);
  380. #else
  381. #define ex_halbtc8821c1ant_power_on_setting(btc)
  382. #define ex_halbtc8821c1ant_pre_load_firmware(btc)
  383. #define ex_halbtc8821c1ant_init_hw_config(btc, wifi_only)
  384. #define ex_halbtc8821c1ant_init_coex_dm(btc)
  385. #define ex_halbtc8821c1ant_ips_notify(btc, type)
  386. #define ex_halbtc8821c1ant_lps_notify(btc, type)
  387. #define ex_halbtc8821c1ant_scan_notify(btc, type)
  388. #define ex_halbtc8821c1ant_switchband_notify(btc, type)
  389. #define ex_halbtc8821c1ant_connect_notify(btc, type)
  390. #define ex_halbtc8821c1ant_media_status_notify(btc, type)
  391. #define ex_halbtc8821c1ant_specific_packet_notify(btc, type)
  392. #define ex_halbtc8821c1ant_bt_info_notify(btc, tmp_buf, length)
  393. #define ex_halbtc8821c1ant_wl_fwdbginfo_notify(btc, tmp_buf, length)
  394. #define ex_halbtc8821c1ant_rx_rate_change_notify(btc, is_data_frame, \
  395. btc_rate_id)
  396. #define ex_halbtc8821c1ant_tx_rate_change_notify(btcoexist, tx_rate, \
  397. tx_retry_ratio, macid)
  398. #define ex_halbtc8821c1ant_rf_status_notify(btc, type)
  399. #define ex_halbtc8821c1ant_halt_notify(btc)
  400. #define ex_halbtc8821c1ant_pnp_notify(btc, pnp_state)
  401. #define ex_halbtc8821c1ant_coex_dm_reset(btc)
  402. #define ex_halbtc8821c1ant_periodical(btc)
  403. #define ex_halbtc8821c1ant_display_simple_coex_info(btc)
  404. #define ex_halbtc8821c1ant_display_coex_info(btc)
  405. #endif
  406. #endif