mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
change(bt): use new retention api to implement BT mac and bb retention
This commit is contained in:
parent
57c8fdfd86
commit
c0f3570237
@ -512,9 +512,10 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
}
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
static esp_err_t sleep_modem_ble_mac_retention_init(void *arg)
|
||||
{
|
||||
uint8_t size;
|
||||
int extra = *(int *)arg;
|
||||
const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra);
|
||||
esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_BT_MAC_BB, SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
@ -523,9 +524,27 @@ static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
return err;
|
||||
}
|
||||
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
{
|
||||
int retention_args = extra;
|
||||
sleep_retention_module_init_param_t init_param = {
|
||||
.cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
|
||||
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB)
|
||||
};
|
||||
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static void sleep_modem_ble_mac_modem_state_deinit(void)
|
||||
{
|
||||
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
esp_err_t err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
assert(err == ESP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
|
||||
|
@ -501,9 +501,10 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
static esp_err_t sleep_modem_ble_mac_retention_init(void *arg)
|
||||
{
|
||||
uint8_t size;
|
||||
int extra = *(int *)arg;
|
||||
const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra);
|
||||
esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_BT_MAC_BB, SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
@ -512,9 +513,27 @@ static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
return err;
|
||||
}
|
||||
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
{
|
||||
int retention_args = extra;
|
||||
sleep_retention_module_init_param_t init_param = {
|
||||
.cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
|
||||
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB)
|
||||
};
|
||||
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static void sleep_modem_ble_mac_modem_state_deinit(void)
|
||||
{
|
||||
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
esp_err_t err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
assert(err == ESP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
|
||||
|
@ -28,7 +28,7 @@ static const char* TAG = "btbb_init";
|
||||
#define BTBB_LINK_OWNER ENTRY(0) | ENTRY(2)
|
||||
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG
|
||||
|
||||
static esp_err_t btbb_sleep_retention_init(void)
|
||||
static esp_err_t btbb_sleep_retention_init(void *arg)
|
||||
{
|
||||
const static sleep_retention_entries_config_t btbb_regs_retention[] = {
|
||||
[0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_BT_BB_LINK(0x00), BB_PART_0_ADDR, BB_PART_0_ADDR, BB_PART_0_SIZE, 0, 0), .owner = BTBB_LINK_OWNER },
|
||||
@ -37,13 +37,20 @@ static esp_err_t btbb_sleep_retention_init(void)
|
||||
};
|
||||
esp_err_t err = sleep_retention_entries_create(btbb_regs_retention, ARRAY_SIZE(btbb_regs_retention), REGDMA_LINK_PRI_BT_MAC_BB, SLEEP_RETENTION_MODULE_BT_BB);
|
||||
ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for btbb retention");
|
||||
ESP_LOGI(TAG, "btbb sleep retention initialization");
|
||||
ESP_LOGD(TAG, "btbb sleep retention initialization");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void btbb_sleep_retention_deinit(void)
|
||||
{
|
||||
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_BT_BB);
|
||||
esp_err_t err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_BT_BB);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "failed to destroy sleep retention linked list for btbb retention");
|
||||
}
|
||||
err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_BT_BB);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Modem BT BB retention callback unregister failed");
|
||||
}
|
||||
}
|
||||
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
|
||||
@ -54,7 +61,19 @@ void esp_btbb_enable(void)
|
||||
if (s_btbb_access_ref == 0) {
|
||||
bt_bb_v2_init_cmplx(BTBB_ENABLE_VERSION_PRINT);
|
||||
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
btbb_sleep_retention_init();
|
||||
sleep_retention_module_init_param_t init_param = {
|
||||
.cbs = { .create = { .handle = btbb_sleep_retention_init, .arg = NULL } },
|
||||
.depends = BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM)
|
||||
};
|
||||
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BT_BB, &init_param);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_BT_BB);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "failed to allocate sleep retention linked list for btbb retention");
|
||||
}
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Modem BT BB retention callback register failed");
|
||||
}
|
||||
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
}
|
||||
s_btbb_access_ref++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user