fix(i2s): lock APB when using apll with DFS feature

Closes https://github.com/espressif/esp-idf/issues/14707

Append to the commit ad9021a844.
This commit is contained in:
laokaiyao
2024-12-31 18:32:30 +08:00
parent 69bd12d792
commit 409397f181
10 changed files with 49 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -245,6 +245,13 @@ esp_err_t i2s_channel_init_std_mode(i2s_chan_handle_t handle, const i2s_std_conf
#ifdef CONFIG_PM_ENABLE
esp_pm_lock_type_t pm_type = ESP_PM_APB_FREQ_MAX;
#if SOC_I2S_SUPPORTS_APLL && SOC_I2S_HW_VERSION_2
if (std_cfg->clk_cfg.clk_src == I2S_CLK_SRC_APLL) {
/* Only I2S HW 2 supports to adjust APB frequency while using APLL clock source
* HW 1 will have timing issue because the DMA and I2S are under different clock domains */
pm_type = ESP_PM_NO_LIGHT_SLEEP;
}
#endif // SOC_I2S_SUPPORTS_APLL
ESP_RETURN_ON_ERROR(esp_pm_lock_create(pm_type, 0, "i2s_driver", &handle->pm_lock), TAG, "I2S pm lock create failed");
#endif
@@ -293,8 +300,10 @@ esp_err_t i2s_channel_reconfig_std_clock(i2s_chan_handle_t handle, const i2s_std
if (std_cfg->clk_cfg.clk_src != clk_cfg->clk_src) {
ESP_GOTO_ON_ERROR(esp_pm_lock_delete(handle->pm_lock), err, TAG, "I2S delete old pm lock failed");
esp_pm_lock_type_t pm_type = ESP_PM_APB_FREQ_MAX;
#if SOC_I2S_SUPPORTS_APLL
#if SOC_I2S_SUPPORTS_APLL && SOC_I2S_HW_VERSION_2
if (clk_cfg->clk_src == I2S_CLK_SRC_APLL) {
/* Only I2S HW 2 supports to adjust APB frequency while using APLL clock source
* HW 1 will have timing issue because the DMA and I2S are under different clock domains */
pm_type = ESP_PM_NO_LIGHT_SLEEP;
}
#endif // SOC_I2S_SUPPORTS_APLL