1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: Header file for hal_coex_reg.c. 15 */ 16 17 #ifndef HAL_COEX_REG_ROM_H 18 #define HAL_COEX_REG_ROM_H 19 20 /***************************************************************************** 21 其他头文件包含 22 *****************************************************************************/ 23 24 #include "oal_ext_if_rom.h" 25 #include "hal_device_rom.h" 26 #include "hal_chip_rom.h" 27 #include "hal_soc_reg.h" 28 #include "hal_gp_reg_rom.h" 29 30 #ifdef __cplusplus 31 #if __cplusplus 32 extern "C" { 33 #endif 34 #endif 35 36 /*****************************************************************************/ 37 /* WiFi状态存储寄存器,GP_REG2(0x40019388) 32bit */ 38 /* | 1 | 4 | 4 | 1 | 22 | */ 39 /* | wlan_on | channel | band_width | wlan_con | rsv | */ 40 /*****************************************************************************/ 41 42 /*****************************************************************************************/ 43 /* BSLE状态存储寄存器,GP_REG3(0x4001938C) 32bit */ 44 /* | 1 | 1 | 1 | 1 | 1 | 1 | 5 | 21 | */ 45 /* | ble_on | ble_scan | ble_adv | ble_init | ble_con | ble_hid | ble_con_num | rsv | */ 46 /*****************************************************************************************/ 47 48 /******************************************************************************/ 49 /* BSLE请求寄存器器,COEX_GP_REG0(0x40017010) 16bit */ 50 /* | 1 | 15 | */ 51 /* | req_ba | rsv | */ 52 /******************************************************************************/ 53 54 #define BLE_STATUS_MASK 0xFFFF 55 #define BT_STATUS_OFFSET 16 56 57 #define BT_ACL_STATUS_MASK (BIT14) 58 #define BT_SCO_STATUS_MASK (BIT4) 59 #define BT_M2S_6SLOT_MASK (BIT0) 60 #define BT_M2S_LDAC_MASK (BIT1) 61 #define BT_M2S_A2DP_MASK (BIT3) 62 #define BT_ACL_STATUS_OFFSET_LEN 14 63 #define BT_SCO_STATUS_OFFSET_LEN 4 64 #define BTCOEX_POWSAVE_TIMEOUT_LEVEL0 100 // 音乐或者数传 ps时间 ms 蓝牙可能重传较多时,由65ms改成100ms 65 #define BTCOEX_POWSAVE_TIMEOUT_LEVEL1 200 // page或inquiry或ldac时间 ms 66 #define BTCOEX_POWSAVE_TIMEOUT_LEVEL2 300 // a2dp|transfer和page或inquiry的ps时间 67 #define BTCOEX_S2M_RESUME_TIMEOUT 3000 // 切回mimo 状态等待时间 68 /* wifi状态结构体, GP_REG2(0x40019388) 32bit */ 69 typedef struct { /* 73仅启用前三个状态 */ 70 osal_u32 wlan_on : 1, /* WIFI:1:on,0:off */ 71 wlan_chan_num : 4, /* 信道:1-14 */ 72 wlan_bandwidth : 4, /* 带宽: 20/40M */ 73 wlan_connect : 1, /* 连接 */ 74 wlan_sleep : 1, /* 睡眠 */ 75 wlan_scan : 1, /* 扫描 */ 76 wlan_ps_stop : 1, /* 停止ps机制 */ 77 wlan_fre : 1, /* 频段 */ 78 wlan_p2p_scan : 1, /* p2p扫描 */ 79 wlan_p2p_conn : 1, /* p2p连接 */ 80 wlan_dbac : 4, /* dbac状态 */ 81 wlan_diff_chan : 1, /* dbac下多信道共存 */ 82 wlan_joining : 1, /* sta加入ap */ 83 wlan_pro_11bgn : 1, /* 11bgn协议 */ 84 wlan_pro_11ax : 1, /* 11ax协议 */ 85 wlan_ps_slot_step : 2, /* ps请求申请提前量 */ 86 wlan_rsv : 6; 87 } wifi_status_stru; 88 89 typedef union { 90 wifi_status_stru wifi_status; 91 osal_u32 u32; 92 } wifi_status_union; 93 94 typedef struct { 95 osal_u16 bt_on : 1, 96 bt_inquiry : 1, 97 bt_page : 1, 98 bt_a2dp : 1, 99 bt_sco : 1, 100 bt_data_send : 1, // acl data send 101 bt_data_rcv : 1, // acl data recv 102 bt_transfer : 1, // not use (only wifi self) bt_data_send || bt_data_rcv 103 bt_6slot : 2, // BT soc slot, 12slot=1, 6solt=2 104 bt_ldac : 3, // a2dp_code状态:2/3为ldac,wifi侧处理时,重设1为ldac, 其他为0 105 bt_acl : 1, // 蓝牙有业务时,通过wifi发送ps状态给路由 106 bt_ba : 1, // not use (only wifi self) 107 bt_resv : 1; 108 } bt_status_stru; 109 110 /* BSLE状态存储寄存器,GP_REG3(0x4001938C) 32bit */ 111 typedef union { 112 osal_u16 bt_status_reg; 113 bt_status_stru bt_status; 114 } btcoex_bt_status_union; 115 116 typedef struct { 117 osal_u32 ble_on : 1, // 只要有ble_scan,ble_adv,ble_init,ble_con有一个启动, 就为1 118 ble_scan : 1, // BLE进入扫描状态 119 ble_adv : 1, // BLE起业务时, 有广播发送 120 ble_init : 1, // 有ble设备创建连接时, 才设置1 121 ble_con : 1, // ble设备已经建立连接 122 ble_hid : 1, // BLE HID设备 123 ble_con_num : 5, // ble总连接数 124 ble_rsv : 21; 125 } ble_status_stru; 126 127 typedef union { 128 osal_u32 ble_status_reg; 129 ble_status_stru ble_status; 130 } btcoex_ble_status_union; 131 132 typedef struct { 133 osal_u16 req_ba : 1, // 请求删建0/1 134 req_ps : 1, // 请求ps操作 135 req_rsv : 14; 136 } bsle_req_stru; 137 138 typedef union { 139 osal_u16 ble_req_reg; 140 bsle_req_stru ble_req; 141 } btcoex_ble_req_union; 142 143 typedef struct hal_btcoex_btble_status { 144 btcoex_ble_status_union ble_status; 145 btcoex_bt_status_union bt_status; 146 btcoex_ble_req_union action_req; 147 osal_u16 rsv; 148 } hal_btcoex_btble_status_stru; 149 150 typedef struct hal_btcoex_btble_status_msg { 151 ble_status_stru ble_status; 152 bt_status_stru bt_status; 153 bsle_req_stru action_req; 154 osal_u16 rsv; 155 osal_u32 timestamp; 156 } hal_btcoex_btble_status_msg_stru; 157 158 typedef struct { 159 osal_u8 abort_duration_on; // abort统计开关 160 osal_u8 msl_cnt_enable; // ps事件延迟时间统计开关 161 osal_u8 post_dev_enable; // 抛事件到device侧的开关 162 osal_u8 rsv; 163 osal_u32 abort_duration_start_us; // abort_start的时刻 164 osal_u32 abort_duration_us; // abort_start-abort_end的时间累计和 165 osal_u32 abort_duration_; // abort_duration_us超过1s的次数 166 167 osal_u32 msl_intr_cnt[HAL_BTCOEX_PS_BUTT]; // 两次维测命令期间mode_slect中断发生的次数 168 osal_u32 msl_bt_duration[HAL_BTCOEX_PS_BUTT]; // 两次维测命令期间mode_slect为低的次数 169 osal_u32 abort_start_cnt[HAL_BTCOEX_PS_BUTT]; // 两次维测命令期间abort_start中断发生的次数 170 osal_u32 ps_on_duration; // 两次维测命令期间处在ps_on的总时间 171 osal_u32 ps_on_last; // 记录上次ps_on开始时刻 172 osal_u32 abort_start_last; // 记录上次abort_start次数 173 osal_u16 ps_msg_delay[8]; // 分别记录ps事件 1~8ms delay 次数 174 175 /* DFX命令行使用 */ 176 osal_u32 timestamp_record; 177 } hal_btcoex_statistics_stru; 178 179 /***************************************************************************** 180 函数声明 181 *****************************************************************************/ 182 hal_btcoex_btble_status_stru *hal_btcoex_btble_status(osal_void); 183 hal_btcoex_statistics_stru *hal_btcoex_statistics(osal_void); 184 osal_void hal_btcoex_abort_start_isr(hal_device_stru *hal_device, osal_u8 data); 185 osal_void hal_btcoex_mode_select_end_isr(hal_device_stru *hal_device, osal_u8 data); 186 osal_void hal_btcoex_abort_end_isr(hal_device_stru *hal_device, osal_u8 data); 187 osal_void hal_btcoex_unregister_irq(osal_void); 188 osal_void hal_btcoex_register_irq(osal_void); 189 osal_void hal_btcoex_process_pm(hal_work_sub_state_uint8 last, hal_work_sub_state_uint8 curr); 190 osal_void hal_set_btcoex_hw_rx_priority_dis(oal_bool_enum_uint8 hw_rx_prio_dis); 191 osal_void hal_set_btcoex_sw_all_abort_ctrl(oal_bool_enum_uint8 sw_abort_ctrl); 192 osal_void hal_set_btcoex_abort_null_buff_addr(osal_u32 abort_null_buff_addr); 193 osal_void hal_update_btcoex_btble_status(hal_btcoex_btble_status_stru *st_cur); 194 osal_void hal_set_btcoex_occupied_period(osal_u16 occupied_period); 195 osal_void hal_btcoex_sync_rf_phy_cb(mac_channel_stru *channel); 196 osal_void hal_btcoex_config_rf_reg2phy(mac_channel_stru *channel); 197 osal_void hal_btcoex_wait_bt_release_rf(osal_void); 198 osal_void hal_btcoex_set_waite_rf_timeout(osal_u32 timeout); 199 typedef osal_u32 (*process_bt_status_cb)(osal_void); 200 typedef osal_void (*sync_rf_phy_cb)(mac_channel_stru *channel); 201 typedef osal_void (*process_mode_select_cb)(osal_void); 202 typedef osal_u32 (*process_pm_cb)(hal_work_sub_state_uint8 last, hal_work_sub_state_uint8 curr); 203 osal_s32 hal_irq_coex_isr(osal_s32 p1, osal_void *p2); 204 // 原host函数 205 hal_btcoex_btble_status_stru *hal_btcoex_btble_status_last(osal_void); 206 hal_btcoex_btble_status_stru *hal_btcoex_btble_status(osal_void); 207 hal_btcoex_statistics_stru *hal_btcoex_statistics(osal_void); 208 osal_void hal_device_set_state_btcoex_notify(oal_bool_enum_uint8 wifi_work); 209 osal_void hal_device_btcoex_sw_init(hal_to_dmac_device_stru *hal_device_base); 210 osal_void hal_btcoex_sw_preempt_exit(hal_to_dmac_device_stru *hal_device); 211 osal_void hal_btcoex_clear_reg(osal_void); 212 osal_void hal_btcoex_get_ps_service_status(const hal_to_dmac_device_stru *hal_device, 213 hal_btcoex_ps_status_enum_uint8 *ps_status); 214 osal_void hal_btcoex_get_bt_sco_status(const hal_to_dmac_device_stru *hal_device, 215 oal_bool_enum_uint8 *sco_status); 216 217 osal_void hal_set_btcoex_hw_rx_priority_dis(oal_bool_enum_uint8 hw_rx_prio_dis); 218 osal_void hal_set_btcoex_hw_priority_en(oal_bool_enum_uint8 hw_prio_en); 219 osal_void hal_set_btcoex_priority_period(osal_u16 priority_period); 220 osal_void hal_set_btcoex_abort_qos_null_seq_num(hal_to_dmac_device_stru *hal_device, 221 osal_u32 qosnull_seq_num); 222 osal_void hal_get_btcoex_abort_qos_null_seq_num(hal_to_dmac_device_stru *hal_device, 223 osal_u32 *qosnull_seq_num); 224 osal_void hal_set_btcoex_abort_preempt_frame_param(osal_u16 preempt_param); 225 osal_void hal_set_btcoex_tx_abort_preempt_type(hal_coex_hw_preempt_mode_enum_uint8 preempt_type); 226 osal_void hal_coex_sw_irq_set(hal_coex_sw_irq_type_enum_uint8 coex_irq_type); 227 osal_void hal_set_btcoex_wifi_status_notify(hal_btcoex_wifi_state_id_enum_uint8 id, osal_u32 val); 228 osal_void hal_device_set_state_btcoex_notify(oal_bool_enum_uint8 wifi_work); 229 osal_void hal_update_btcoex_btble_status(hal_btcoex_btble_status_stru *st_cur); 230 osal_void hal_btcoex_sync_btble_status(hal_btcoex_btble_status_msg_stru *status_msg); 231 osal_void hal_btcoex_get_abort_cnt(hal_to_dmac_chip_stru *hal_chip, 232 osal_u32 *abort_start, osal_u32 *abort_done, osal_u32 *abort_end); 233 osal_u32 hal_btcoex_update_ap_beacon_count(osal_void); 234 osal_void hal_coex_notify_irq_en(osal_u8 intr_en); 235 236 #ifdef __cplusplus 237 #if __cplusplus 238 } 239 #endif 240 #endif 241 242 243 #endif 244