5858
5959#include "hal/efuse_hal.h"
6060#include "soc/rtc.h"
61+ #include "modem/modem_syscon_struct.h"
6162
6263#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
6364#include "ble_log/ble_log_spi_out.h"
7071#define OSI_COEX_VERSION 0x00010006
7172#define OSI_COEX_MAGIC_VALUE 0xFADEBEAD
7273
73- #define EXT_FUNC_VERSION 0x20240422
74+ #define EXT_FUNC_VERSION 0x20250415
7475#define EXT_FUNC_MAGIC_VALUE 0xA5A5A5A5
7576
7677#define BT_ASSERT_PRINT ets_printf
@@ -101,7 +102,9 @@ struct ext_funcs_t {
101102 int (* _ecc_gen_key_pair )(uint8_t * public , uint8_t * priv );
102103 int (* _ecc_gen_dh_key )(const uint8_t * remote_pub_key_x , const uint8_t * remote_pub_key_y ,
103104 const uint8_t * local_priv_key , uint8_t * dhkey );
104- void (* _esp_reset_rpa_moudle )(void );
105+ #if CONFIG_IDF_TARGET_ESP32C6
106+ void (* _esp_reset_modem )(uint8_t mdl_opts , uint8_t start );
107+ #endif // CONFIG_IDF_TARGET_ESP32C6
105108 uint32_t magic ;
106109};
107110
@@ -112,6 +115,11 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t le
112115/* External functions or variables
113116 ************************************************************************
114117 */
118+ #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
119+ extern void coex_hw_timer_set (uint8_t idx ,uint8_t src , uint8_t pti ,uint32_t latency , uint32_t perioidc );
120+ extern void coex_hw_timer_enable (uint8_t idx );
121+ extern void coex_hw_timer_disable (uint8_t idx );
122+ #endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
115123extern int ble_osi_coex_funcs_register (struct osi_coex_funcs_t * coex_funcs );
116124extern int r_ble_controller_init (esp_bt_controller_config_t * cfg );
117125extern void esp_ble_controller_info_capture (uint32_t cycle_times );
@@ -185,7 +193,9 @@ static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler,
185193static int esp_intr_free_wrapper (void * * ret_handle );
186194static void osi_assert_wrapper (const uint32_t ln , const char * fn , uint32_t param1 , uint32_t param2 );
187195static uint32_t osi_random_wrapper (void );
188- static void esp_reset_rpa_moudle (void );
196+ #if CONFIG_IDF_TARGET_ESP32C6
197+ static void esp_reset_modem (uint8_t mdl_opts ,uint8_t start );
198+ #endif // CONFIG_IDF_TARGET_ESP32C6
189199static int esp_ecc_gen_key_pair (uint8_t * pub , uint8_t * priv );
190200static int esp_ecc_gen_dh_key (const uint8_t * peer_pub_key_x , const uint8_t * peer_pub_key_y ,
191201 const uint8_t * our_priv_key , uint8_t * out_dhkey );
@@ -463,15 +473,34 @@ struct ext_funcs_t ext_funcs_ro = {
463473 ._os_random = osi_random_wrapper ,
464474 ._ecc_gen_key_pair = esp_ecc_gen_key_pair ,
465475 ._ecc_gen_dh_key = esp_ecc_gen_dh_key ,
466- ._esp_reset_rpa_moudle = esp_reset_rpa_moudle ,
476+ #if CONFIG_IDF_TARGET_ESP32C6
477+ ._esp_reset_modem = esp_reset_modem ,
478+ #endif // CONFIG_IDF_TARGET_ESP32C6
467479 .magic = EXT_FUNC_MAGIC_VALUE ,
468480};
469481
470- static void IRAM_ATTR esp_reset_rpa_moudle (void )
482+ #if CONFIG_IDF_TARGET_ESP32C6
483+ static void IRAM_ATTR esp_reset_modem (uint8_t mdl_opts ,uint8_t start )
471484{
485+ if (mdl_opts == 0x05 ) {
486+ if (start ) {
487+ #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
488+ coex_hw_timer_set (0x04 , 0x02 , 15 , 0 , 5000 );
489+ coex_hw_timer_enable (0x04 );
490+ #endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
491+ MODEM_SYSCON .modem_rst_conf .val |= (BIT (16 ) | BIT (18 ));
492+ MODEM_SYSCON .modem_rst_conf .val &= ~(BIT (16 ) | BIT (18 ));
493+ } else {
494+ #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
495+ coex_hw_timer_disable (0x04 );
496+ #endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
497+ }
472498
499+ }
473500}
474501
502+ #endif // CONFIG_IDF_TARGET_ESP32C6
503+
475504static void IRAM_ATTR osi_assert_wrapper (const uint32_t ln , const char * fn ,
476505 uint32_t param1 , uint32_t param2 )
477506{
0 commit comments