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