hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#ifndef __INC_BTC_FW_H__
#define __INC_BTC_FW_H__
 
#include "halbtc_fwdef.h"
 
#pragma pack(push)
#pragma pack(1)
 
struct btc_t;
 
struct btf_tlv {
   u8 type;
   u8 len;
   u8 val[1];
};
 
enum btf_reg_type {
   REG_MAC = 0x0,
   REG_BB = 0x1,
   REG_RF = 0x2,
   REG_BT_RF = 0x3,
   REG_BT_MODEM = 0x4,
   REG_BT_BLUEWIZE = 0x5,
   REG_BT_VENDOR = 0x6,
   REG_BT_LE = 0x7,
   REG_MAX_TYPE
};
 
/*
 * h2c_class : 0x10~0x17: BTC
 * Please see : struct rtw_g6_h2c_hdr
 */
enum bt_h2c_class {
   BTFC_SET = 0x10, /* 0x10~0x17 for BTC */
   BTFC_GET = 0x11,
   BTFC_FW_EVENT = 0x12,
   BTFC_MAX
};
 
/* =======================================
 * BTFC_SET class 0x10 ->function
 */
enum btf_set {
   SET_REPORT_EN = 0x0,
   SET_SLOT_TABLE, /* Slot table  */
   SET_MREG_TABLE, /* moniter register  */
   SET_CX_POLICY,
   SET_GPIO_DBG,
   SET_DRV_INFO,
   SET_DRV_EVENT,
   SET_BT_WREG_ADDR,
   SET_BT_WREG_VAL,
   SET_BT_RREG_ADDR,
   SET_BT_WL_CH_INFO,
   SET_BT_INFO_REPORT,
   SET_BT_IGNORE_WLAN_ACT,
   SET_BT_TX_PWR,
   SET_BT_LNA_CONSTRAIN,
   SET_BT_GOLDEN_RX_RANGE,
   SET_BT_PSD_REPORT,
   SET_H2C_TEST,
   SET_MAX1
};
 
/* SET_REPORT_EN function 0x0 -> TLV sub-function */
enum btf_set_report_en {
   RPT_EN_TDMA = BIT0,
   RPT_EN_CYCLE = BIT1,
   RPT_EN_MREG = BIT2,
   RPT_EN_BT_VER_INFO = BIT3, /* FW, Coex, Feature*/
   RPT_EN_BT_SCAN_INFO = BIT4,  /* BT scan parameter */
   RPT_EN_BT_AFH_MAP = BIT5, /* AFH map H/M/L */
   RPT_EN_BT_DEVICE_INFO = BIT6, /* vendor id, device name, flush-val*/
   RPT_EN_FW_STEP_INFO = BIT7,
   RPT_EN_WL_ALL = 0x7,
   RPT_EN_BT_ALL = 0x78,
   RPT_EN_ALL = 0x7f
};
 
/* SET_SLOT_TABLE function 0x1 -> sub-function */
struct btf_set_report {
   u8 fver;
   u32 enable;
   u32 para;
};
 
struct btf_set_slot_table {
   u8 fver;
   u8 tbl_num;
   u8 buf[1];
};
 
/* SET_MREG_TABLE function 0x2 -> sub-function */
struct btf_set_mon_reg {
   u8 fver;
   u8 reg_num;
   u8 buf[1];
};
 
/* SET_CX_POLICY function 0x3 -> TLV sub-function */
enum btf_set_cx_policy {
   CXPOLICY_TDMA = 0x0,
   CXPOLICY_SLOT = 0x1,
   CXPOLICY_TYPE = 0x2,
   CXPOLICY_MAX
};
 
/* SET_GPIO_DBG function 0x4 -> TLV sub-function */
enum {
   CXDGPIO_EN_MAP = 0x0,
   CXDGPIO_MUX_MAP = 0x1,
   CXDGPIO_MAX
};
 
/* SET_DRV_INFO function 0x5 -> TLV sub-function */
enum {
   CXDRVINFO_INIT = 0, /* wl_only, dbcc_en...*/
   CXDRVINFO_ROLE, /* Role */
   CXDRVINFO_DBCC, /* DBCC */
   CXDRVINFO_SMAP, /* status map */
   CXDRVINFO_RFK,  /* wl rfk info */
   CXDRVINFO_RUN,  /* wl run reason */
   CXDRVINFO_CTRL, /* ctrl info */
   CXDRVINFO_SCAN, /* scan info */
   CXDRVINFO_MAX
};
 
/* SET_DRV_EVENT function 0x6 -> TLV sub-function */
enum {
   CXDRVEVNT_1 = 0x0,
   CXDRVEVNT_2 = 0x1,
   CXDRVEVNT_MAX
};
 
/* =======================================
 * BTFC_GET class 0x11 ->function
 */
enum btf_get {
   GET_BT_REG,
   GET_MAX
};
 
/* =======================================
 * BTFC_FW_EVENT class 0x12 ->function
 */
enum btf_fw_event {
   BTF_EVNT_RPT = 0,
   BTF_EVNT_BT_INFO = 1,
   BTF_EVNT_BT_SCBD = 2,
   BTF_EVNT_BT_REG = 3,
   BTF_EVNT_CX_RUNINFO = 4,
   BTF_EVNT_BT_PSD = 5,
   BTF_EVNT_BUF_OVERFLOW,
   BTF_EVNT_C2H_LOOPBACK,
   BTF_EVNT_MAX
};
 
struct btf_event {
   u8 event;
   u8 reserved;
   u16 length;
   u8 buf[1];
};
 
/* BTF_EVNT_RPT function 0x0 -> TLV type */
enum btf_fw_event_report {
   BTC_RPT_TYPE_CTRL = 0x0,
   BTC_RPT_TYPE_TDMA,
   BTC_RPT_TYPE_SLOT,
   BTC_RPT_TYPE_CYSTA,
   BTC_RPT_TYPE_STEP,
   BTC_RPT_TYPE_NULLSTA,
   BTC_RPT_TYPE_MREG,
   BTC_RPT_TYPE_GPIO_DBG,
   BTC_RPT_TYPE_BT_VER,
   BTC_RPT_TYPE_BT_SCAN,
   BTC_RPT_TYPE_BT_AFH,
   BTC_RPT_TYPE_BT_DEVICE,
   BTC_RPT_TYPE_TEST,
   BTC_RPT_TYPE_MAX = 31
};
 
struct btc_rpt_cmn_info {
   u32 rx_cnt;
   u32 rx_len;
   u32 req_len; /* expected rsp len */
   u8 req_fver; /* expected rsp fver */
   u8 rsp_fver; /* fver from fw */
   u8 valid;
};
 
#pragma pack(pop)
 
struct btc_report_ctrl_state {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_rpt_ctrl finfo; /* info from fw */
};
 
struct btc_fbtc_tdma {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_1tdma finfo; /* info from fw */
};
 
struct btc_fbtc_slots {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_slots finfo; /* info from fw */
};
 
struct btc_fbtc_cysta {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_cysta finfo; /* info from fw */
};
 
struct btc_fbtc_step {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_steps finfo; /* info from fw */
};
 
struct btc_fbtc_nullsta {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_cynullsta finfo; /* info from fw */
};
 
struct btc_fbtc_mreg {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_mreg_val finfo; /* info from fw */
};
 
struct btc_fbtc_gpio_dbg {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_gpio_dbg finfo; /* info from fw */
};
 
struct btc_fbtc_btver {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_btver finfo; /* info from fw */
};
 
struct btc_fbtc_btscan {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_btscan finfo; /* info from fw */
};
 
struct btc_fbtc_btafh {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_btafh finfo; /* info from fw */
};
 
struct btc_fbtc_btdev {
   struct btc_rpt_cmn_info cinfo; /* common info, by driver */
   struct fbtc_btdevinfo finfo; /* info from fw */
};
 
enum {
   BTFRE_INVALID_INPUT = 0x0, /* invalid input parameters */
   BTFRE_UNDEF_TYPE,
   BTFRE_EXCEPTION,
   BTFRE_MAX
};
 
struct btf_fwinfo {
   u32 cnt_c2h; /* total c2h cnt */
   u32 cnt_h2c; /* total h2c cnt */
   u32 cnt_h2c_fail; /* total h2c fail cnt */
   u32 event[BTF_EVNT_MAX]; /* event statistics */
 
   u32 err[BTFRE_MAX]; /* counters for statistics */
   u32 len_mismch; /* req/rsp length mis match */
   u32 fver_mismch; /* req/rsp fver mis match */
   u32 rpt_en_map;
 
   struct btc_report_ctrl_state rpt_ctrl;
   struct btc_fbtc_tdma rpt_fbtc_tdma;
   struct btc_fbtc_slots rpt_fbtc_slots;
   struct btc_fbtc_cysta rpt_fbtc_cysta;
   struct btc_fbtc_step rpt_fbtc_step;
   struct btc_fbtc_nullsta rpt_fbtc_nullsta;
   struct btc_fbtc_mreg rpt_fbtc_mregval;
   struct btc_fbtc_gpio_dbg rpt_fbtc_gpio_dbg;
   struct btc_fbtc_btver rpt_fbtc_btver;
   struct btc_fbtc_btscan rpt_fbtc_btscan;
   struct btc_fbtc_btafh rpt_fbtc_btafh;
   struct btc_fbtc_btdev rpt_fbtc_btdev;
};
 
/*
 * extern functions
 */
 
void _chk_btc_err(struct btc_t *btc, u8 type, u32 cnt);
void hal_btc_fw_event(struct btc_t *btc, u8 evt_id, void *data, u32 len);
void hal_btc_fw_en_rpt(struct btc_t *btc, u32 rpt_map, u32 rpt_state);
void hal_btc_fw_set_slots(struct btc_t *btc, u8 num, struct fbtc_slot *s);
void hal_btc_fw_set_monreg(struct btc_t *btc);
bool hal_btc_fw_set_1tdma(struct btc_t *btc,  u16 len, u8 *buf);
bool hal_btc_fw_set_1slot(struct btc_t *btc,  u16 len, u8 *buf);
bool hal_btc_fw_set_policy(struct btc_t *btc, bool force_exec, u16 policy_type,
              const char* action);
void hal_btc_fw_set_gpio_dbg(struct btc_t *btc, u8 type, u32 val);
void hal_btc_fw_set_drv_info(struct btc_t *btc, u8 type);
void hal_btc_fw_set_bt(struct btc_t *btc, u8 type, u16 len, u8* buf);
void hal_btc_fw_set_drv_event(struct btc_t *btc, u8 type);
void hal_btc_notify_ps_tdma(struct btc_t *btc, bool tdma_start);
 
#endif    /* __INC_BTC_FW_H__ */