net: wireless: rockchip_wlan: add rtl8723ds support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723ds / hal / btc / HalBtc8723b1Ant.h
1 \r
2 #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1)\r
3 \r
4 #if (RTL8723B_SUPPORT == 1)\r
5 /* *******************************************\r
6  * The following is for 8723B 1ANT BT Co-exist definition\r
7  * ******************************************* */\r
8 #define BT_AUTO_REPORT_ONLY_8723B_1ANT                          1\r
9 \r
10 #define BT_INFO_8723B_1ANT_B_FTP                                                BIT(7)\r
11 #define BT_INFO_8723B_1ANT_B_A2DP                                       BIT(6)\r
12 #define BT_INFO_8723B_1ANT_B_HID                                                BIT(5)\r
13 #define BT_INFO_8723B_1ANT_B_SCO_BUSY                           BIT(4)\r
14 #define BT_INFO_8723B_1ANT_B_ACL_BUSY                           BIT(3)\r
15 #define BT_INFO_8723B_1ANT_B_INQ_PAGE                           BIT(2)\r
16 #define BT_INFO_8723B_1ANT_B_SCO_ESCO                           BIT(1)\r
17 #define BT_INFO_8723B_1ANT_B_CONNECTION                         BIT(0)\r
18 \r
19 #define BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_)       \\r
20                 (((_BT_INFO_EXT_&BIT(0))) ? true : false)\r
21 \r
22 #define BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT             2\r
23 \r
24 #define  BT_8723B_1ANT_WIFI_NOISY_THRESH                                                                50 /* 30   //max: 255                                                            */\r
25 \r
26 /* for Antenna detection */\r
27 #define BT_8723B_1ANT_ANTDET_PSDTHRES_BACKGROUND                                                50\r
28 #define BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION                         70\r
29 #define BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION                        55\r
30 #define BT_8723B_1ANT_ANTDET_PSDTHRES_1ANT                                                      32\r
31 #define BT_8723B_1ANT_ANTDET_RETRY_INTERVAL                                                     10      /* retry timer if ant det is fail, unit: second */\r
32 #define BT_8723B_1ANT_ANTDET_SWEEPPOINT_DELAY                                                   40000  \r
33 #define BT_8723B_1ANT_ANTDET_ENABLE                                                                             1\r
34 #define BT_8723B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE                         1\r
35 #define BT_8723B_1ANT_ANTDET_BTTXTIME                                                                   100\r
36 #define BT_8723B_1ANT_ANTDET_BTTXCHANNEL                                                                39\r
37 \r
38 enum bt_info_src_8723b_1ant {\r
39         BT_INFO_SRC_8723B_1ANT_WIFI_FW                  = 0x0,\r
40         BT_INFO_SRC_8723B_1ANT_BT_RSP                           = 0x1,\r
41         BT_INFO_SRC_8723B_1ANT_BT_ACTIVE_SEND           = 0x2,\r
42         BT_INFO_SRC_8723B_1ANT_MAX\r
43 };\r
44 \r
45 enum bt_8723b_1ant_bt_status {\r
46         BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE      = 0x0,\r
47         BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE          = 0x1,\r
48         BT_8723B_1ANT_BT_STATUS_INQ_PAGE                                = 0x2,\r
49         BT_8723B_1ANT_BT_STATUS_ACL_BUSY                                = 0x3,\r
50         BT_8723B_1ANT_BT_STATUS_SCO_BUSY                                = 0x4,\r
51         BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY                    = 0x5,\r
52         BT_8723B_1ANT_BT_STATUS_MAX\r
53 };\r
54 \r
55 enum bt_8723b_1ant_wifi_status {\r
56         BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE                            = 0x0,\r
57         BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN          = 0x1,\r
58         BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN                                        = 0x2,\r
59         BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIFIC_PKT                                = 0x3,\r
60         BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE                                        = 0x4,\r
61         BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY                                        = 0x5,\r
62         BT_8723B_1ANT_WIFI_STATUS_MAX\r
63 };\r
64 \r
65 enum bt_8723b_1ant_coex_algo {\r
66         BT_8723B_1ANT_COEX_ALGO_UNDEFINED                       = 0x0,\r
67         BT_8723B_1ANT_COEX_ALGO_SCO                             = 0x1,\r
68         BT_8723B_1ANT_COEX_ALGO_HID                             = 0x2,\r
69         BT_8723B_1ANT_COEX_ALGO_A2DP                            = 0x3,\r
70         BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS              = 0x4,\r
71         BT_8723B_1ANT_COEX_ALGO_PANEDR                  = 0x5,\r
72         BT_8723B_1ANT_COEX_ALGO_PANHS                   = 0x6,\r
73         BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP             = 0x7,\r
74         BT_8723B_1ANT_COEX_ALGO_PANEDR_HID              = 0x8,\r
75         BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9,\r
76         BT_8723B_1ANT_COEX_ALGO_HID_A2DP                        = 0xa,\r
77         BT_8723B_1ANT_COEX_ALGO_MAX                             = 0xb,\r
78 };\r
79 \r
80 struct coex_dm_8723b_1ant {\r
81         /* hw setting */\r
82         u8              pre_ant_pos_type;\r
83         u8              cur_ant_pos_type;\r
84         /* fw mechanism */\r
85         boolean         cur_ignore_wlan_act;\r
86         boolean         pre_ignore_wlan_act;\r
87         u8              pre_ps_tdma;\r
88         u8              cur_ps_tdma;\r
89         u8              ps_tdma_para[5];\r
90         u8              ps_tdma_du_adj_type;\r
91         boolean         auto_tdma_adjust;\r
92         boolean         pre_ps_tdma_on;\r
93         boolean         cur_ps_tdma_on;\r
94         boolean         pre_bt_auto_report;\r
95         boolean         cur_bt_auto_report;\r
96         u8              pre_lps;\r
97         u8              cur_lps;\r
98         u8              pre_rpwm;\r
99         u8              cur_rpwm;\r
100 \r
101         /* sw mechanism */\r
102         boolean pre_low_penalty_ra;\r
103         boolean         cur_low_penalty_ra;\r
104         u32             pre_val0x6c0;\r
105         u32             cur_val0x6c0;\r
106         u32             pre_val0x6c4;\r
107         u32             cur_val0x6c4;\r
108         u32             pre_val0x6c8;\r
109         u32             cur_val0x6c8;\r
110         u8              pre_val0x6cc;\r
111         u8              cur_val0x6cc;\r
112 \r
113         u32             backup_arfr_cnt1;       /* Auto Rate Fallback Retry cnt */\r
114         u32             backup_arfr_cnt2;       /* Auto Rate Fallback Retry cnt */\r
115         u16             backup_retry_limit;\r
116         u8              backup_ampdu_max_time;\r
117 \r
118         /* algorithm related */\r
119         u8              bt_status;\r
120         u8              wifi_chnl_info[3];\r
121 \r
122         u32             pre_ra_mask;\r
123         u32             cur_ra_mask;\r
124         u8              pre_arfr_type;\r
125         u8              cur_arfr_type;\r
126         u8              pre_retry_limit_type;\r
127         u8              cur_retry_limit_type;\r
128         u8              pre_ampdu_time_type;\r
129         u8              cur_ampdu_time_type;\r
130         u32             arp_cnt;\r
131 \r
132         u8              error_condition;\r
133 };\r
134 \r
135 struct coex_sta_8723b_1ant {\r
136         boolean                                 bt_disabled;\r
137         boolean                                 bt_link_exist;\r
138         boolean                                 sco_exist;\r
139         boolean                                 a2dp_exist;\r
140         boolean                                 hid_exist;\r
141         boolean                                 pan_exist;\r
142         boolean                                 bt_hi_pri_link_exist;\r
143         u8                                      num_of_profile;\r
144         boolean                                 bt_abnormal_scan;\r
145 \r
146         boolean                                 under_lps;\r
147         boolean                                 under_ips;\r
148         u32                                     specific_pkt_period_cnt;\r
149         u32                                     high_priority_tx;\r
150         u32                                     high_priority_rx;\r
151         u32                                     low_priority_tx;\r
152         u32                                     low_priority_rx;\r
153         s8                                      bt_rssi;\r
154         boolean                                 bt_tx_rx_mask;\r
155         boolean                                 c2h_bt_info_req_sent;\r
156         u8                                      bt_info_c2h[BT_INFO_SRC_8723B_1ANT_MAX][10];\r
157         u32                                     bt_info_c2h_cnt[BT_INFO_SRC_8723B_1ANT_MAX];\r
158         boolean                                 bt_whck_test;\r
159         boolean                                 c2h_bt_inquiry_page;\r
160         boolean                                 c2h_bt_remote_name_req;\r
161         boolean                                 wifi_is_high_pri_task;          /* Add for win8.1 page out issue */\r
162         u8                                      bt_retry_cnt;\r
163         u8                                      bt_info_ext;\r
164         u32                                     pop_event_cnt;\r
165         u8                                      scan_ap_num;\r
166 \r
167         u32                                     crc_ok_cck;\r
168         u32                                     crc_ok_11g;\r
169         u32                                     crc_ok_11n;\r
170         u32                                     crc_ok_11n_agg;\r
171         \r
172         u32                                     crc_err_cck;\r
173         u32                                     crc_err_11g;\r
174         u32                                     crc_err_11n;\r
175         u32                                     crc_err_11n_agg;\r
176 \r
177         boolean                                 cck_lock;\r
178         boolean                                 pre_ccklock;\r
179         boolean                                 cck_ever_lock;\r
180         u8                                      coex_table_type;\r
181 \r
182         boolean                                 force_lps_on;\r
183         u32                                     wrong_profile_notification;\r
184 \r
185         u8                                      a2dp_bit_pool;\r
186         u8                                      cut_version;\r
187 };\r
188 \r
189 #define BT_8723B_1ANT_ANTDET_PSD_POINTS                 256     /* MAX:1024 */\r
190 #define BT_8723B_1ANT_ANTDET_PSD_AVGNUM         1       /* MAX:3 */\r
191 #define BT_8723B_1ANT_ANTDET_BUF_LEN                    16\r
192 \r
193 struct psdscan_sta_8723b_1ant {\r
194 \r
195         u32                     ant_det_bt_le_channel;  /* BT LE Channel ex:2412 */\r
196         u32                     ant_det_bt_tx_time;\r
197         u32                     ant_det_pre_psdscan_peak_val;\r
198         boolean                 ant_det_is_ant_det_available;\r
199         u32                     ant_det_psd_scan_peak_val;\r
200         boolean                 ant_det_is_btreply_available;\r
201         u32                     ant_det_psd_scan_peak_freq;\r
202 \r
203         u8                      ant_det_result;\r
204         u8                      ant_det_peak_val[BT_8723B_1ANT_ANTDET_BUF_LEN];\r
205         u8                      ant_det_peak_freq[BT_8723B_1ANT_ANTDET_BUF_LEN];\r
206         u32                     ant_det_try_count;\r
207         u32                     ant_det_fail_count;\r
208         u32                     ant_det_inteval_count;\r
209         u32                     ant_det_thres_offset;\r
210 \r
211         u32                     real_cent_freq;\r
212         s32                     real_offset;\r
213         u32                     real_span;\r
214         \r
215         u32                     psd_band_width;  /* unit: Hz */\r
216         u32                     psd_point;              /* 128/256/512/1024 */\r
217         u32                     psd_report[1024];  /* unit:dB (20logx), 0~255 */\r
218         u32                     psd_report_max_hold[1024];  /* unit:dB (20logx), 0~255 */\r
219         u32                     psd_start_point;\r
220         u32                     psd_stop_point;\r
221         u32                     psd_max_value_point;\r
222         u32                     psd_max_value;\r
223         u32                     psd_start_base;\r
224         u32                     psd_avg_num;    /* 1/8/16/32 */\r
225         u32                     psd_gen_count;\r
226         boolean                 is_psd_running;\r
227         boolean                 is_psd_show_max_only;\r
228 };\r
229 \r
230 /* *******************************************\r
231  * The following is interface which will notify coex module.\r
232  * ******************************************* */\r
233 void ex_halbtc8723b1ant_power_on_setting(IN struct btc_coexist *btcoexist);\r
234 void ex_halbtc8723b1ant_pre_load_firmware(IN struct btc_coexist *btcoexist);\r
235 void ex_halbtc8723b1ant_init_hw_config(IN struct btc_coexist *btcoexist,\r
236                                        IN boolean wifi_only);\r
237 void ex_halbtc8723b1ant_init_coex_dm(IN struct btc_coexist *btcoexist);\r
238 void ex_halbtc8723b1ant_ips_notify(IN struct btc_coexist *btcoexist,\r
239                                    IN u8 type);\r
240 void ex_halbtc8723b1ant_lps_notify(IN struct btc_coexist *btcoexist,\r
241                                    IN u8 type);\r
242 void ex_halbtc8723b1ant_scan_notify(IN struct btc_coexist *btcoexist,\r
243                                     IN u8 type);\r
244 void ex_halbtc8723b1ant_connect_notify(IN struct btc_coexist *btcoexist,\r
245                                        IN u8 type);\r
246 void ex_halbtc8723b1ant_media_status_notify(IN struct btc_coexist *btcoexist,\r
247                 IN u8 type);\r
248 void ex_halbtc8723b1ant_specific_packet_notify(IN struct btc_coexist *btcoexist,\r
249                 IN u8 type);\r
250 void ex_halbtc8723b1ant_bt_info_notify(IN struct btc_coexist *btcoexist,\r
251                                        IN u8 *tmp_buf, IN u8 length);\r
252 void ex_halbtc8723b1ant_rf_status_notify(IN struct btc_coexist *btcoexist,\r
253                 IN u8 type);\r
254 void ex_halbtc8723b1ant_halt_notify(IN struct btc_coexist *btcoexist);\r
255 void ex_halbtc8723b1ant_pnp_notify(IN struct btc_coexist *btcoexist,\r
256                                    IN u8 pnp_state);\r
257 void ex_halbtc8723b1ant_coex_dm_reset(IN struct btc_coexist *btcoexist);\r
258 void ex_halbtc8723b1ant_periodical(IN struct btc_coexist *btcoexist);\r
259 void ex_halbtc8723b1ant_display_coex_info(IN struct btc_coexist *btcoexist);\r
260 void ex_halbtc8723b1ant_antenna_detection(IN struct btc_coexist *btcoexist,\r
261                 IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds);\r
262 \r
263 void ex_halbtc8723b1ant_display_ant_detection(IN struct btc_coexist *btcoexist);\r
264 \r
265 #else\r
266 #define ex_halbtc8723b1ant_power_on_setting(btcoexist)\r
267 #define ex_halbtc8723b1ant_pre_load_firmware(btcoexist)\r
268 #define ex_halbtc8723b1ant_init_hw_config(btcoexist, wifi_only)\r
269 #define ex_halbtc8723b1ant_init_coex_dm(btcoexist)\r
270 #define ex_halbtc8723b1ant_ips_notify(btcoexist, type)\r
271 #define ex_halbtc8723b1ant_lps_notify(btcoexist, type)\r
272 #define ex_halbtc8723b1ant_scan_notify(btcoexist, type)\r
273 #define ex_halbtc8723b1ant_connect_notify(btcoexist, type)\r
274 #define ex_halbtc8723b1ant_media_status_notify(btcoexist, type)\r
275 #define ex_halbtc8723b1ant_specific_packet_notify(btcoexist, type)\r
276 #define ex_halbtc8723b1ant_bt_info_notify(btcoexist, tmp_buf, length)\r
277 #define ex_halbtc8723b1ant_rf_status_notify(btcoexist, type)\r
278 #define ex_halbtc8723b1ant_halt_notify(btcoexist)\r
279 #define ex_halbtc8723b1ant_pnp_notify(btcoexist, pnp_state)\r
280 #define ex_halbtc8723b1ant_coex_dm_reset(btcoexist)\r
281 #define ex_halbtc8723b1ant_periodical(btcoexist)\r
282 #define ex_halbtc8723b1ant_display_coex_info(btcoexist)\r
283 #define ex_halbtc8723b1ant_antenna_detection(btcoexist, cent_freq, offset, span, seconds)\r
284 #define ex_halbtc8723b1ant_display_ant_detection(btcoexist)\r
285 \r
286 #endif\r
287 \r
288 #endif\r