diff --git a/components/driver/i2s/i2s_common.c b/components/driver/i2s/i2s_common.c index 552368c1b3..3247353517 100644 --- a/components/driver/i2s/i2s_common.c +++ b/components/driver/i2s/i2s_common.c @@ -488,8 +488,19 @@ uint32_t i2s_get_source_clk_freq(i2s_clock_src_t clk_src, uint32_t mclk_freq_hz) (void)mclk_freq_hz; return esp_clk_xtal_freq(); #endif - default: // I2S_CLK_SRC_PLL_160M - return esp_clk_apb_freq() * 2; +#if SOC_I2S_SUPPORTS_PLL_F160M + case I2S_CLK_SRC_PLL_160M: + (void)mclk_freq_hz; + return I2S_LL_PLL_F160M_CLK_FREQ; +#endif +#if SOC_I2S_SUPPORTS_PLL_F96M + case I2S_CLK_SRC_PLL_96M: + (void)mclk_freq_hz; + return I2S_LL_PLL_F96M_CLK_FREQ; +#endif + default: + // Invalid clock source + return 0; } } diff --git a/components/hal/esp32/include/hal/i2s_ll.h b/components/hal/esp32/include/hal/i2s_ll.h index e4b5e34d43..9fc492b087 100644 --- a/components/hal/esp32/include/hal/i2s_ll.h +++ b/components/hal/esp32/include/hal/i2s_ll.h @@ -45,6 +45,8 @@ extern "C" { #define I2S_LL_TX_EVENT_MASK I2S_LL_EVENT_TX_EOF #define I2S_LL_RX_EVENT_MASK I2S_LL_EVENT_RX_EOF +#define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz + /* I2S clock configuration structure */ typedef struct { uint16_t mclk_div; // I2S module clock divider, Fmclk = Fsclk /(mclk_div+b/a) diff --git a/components/hal/esp32c3/include/hal/i2s_ll.h b/components/hal/esp32c3/include/hal/i2s_ll.h index 4448f0ef95..555a878aa8 100644 --- a/components/hal/esp32c3/include/hal/i2s_ll.h +++ b/components/hal/esp32c3/include/hal/i2s_ll.h @@ -32,6 +32,8 @@ extern "C" { #define I2S_LL_MCLK_DIVIDER_BIT_WIDTH (9) #define I2S_LL_MCLK_DIVIDER_MAX ((1 << I2S_LL_MCLK_DIVIDER_BIT_WIDTH) - 1) +#define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz + /* I2S clock configuration structure */ typedef struct { uint16_t mclk_div; // I2S module clock divider, Fmclk = Fsclk /(mclk_div+b/a) diff --git a/components/hal/esp32c6/include/hal/i2s_ll.h b/components/hal/esp32c6/include/hal/i2s_ll.h index aac0bcbddd..3d36a0af89 100644 --- a/components/hal/esp32c6/include/hal/i2s_ll.h +++ b/components/hal/esp32c6/include/hal/i2s_ll.h @@ -33,6 +33,8 @@ extern "C" { #define I2S_LL_MCLK_DIVIDER_BIT_WIDTH (9) #define I2S_LL_MCLK_DIVIDER_MAX ((1 << I2S_LL_MCLK_DIVIDER_BIT_WIDTH) - 1) +#define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz + /* I2S clock configuration structure */ typedef struct { uint16_t mclk_div; // I2S module clock divider, Fmclk = Fsclk /(mclk_div+b/a) diff --git a/components/hal/esp32h4/include/hal/i2s_ll.h b/components/hal/esp32h4/include/hal/i2s_ll.h index a15fe826b3..b19165ad77 100644 --- a/components/hal/esp32h4/include/hal/i2s_ll.h +++ b/components/hal/esp32h4/include/hal/i2s_ll.h @@ -33,6 +33,8 @@ extern "C" { #define I2S_LL_MCLK_DIVIDER_BIT_WIDTH (9) #define I2S_LL_MCLK_DIVIDER_MAX ((1 << I2S_LL_MCLK_DIVIDER_BIT_WIDTH) - 1) +#define I2S_LL_PLL_F96M_CLK_FREQ (96 * 1000000) // PLL_F96M_CLK: 96MHz + /* I2S clock configuration structure */ typedef struct { uint16_t mclk_div; // I2S module clock divider, Fmclk = Fsclk /(mclk_div+b/a) diff --git a/components/hal/esp32s2/include/hal/i2s_ll.h b/components/hal/esp32s2/include/hal/i2s_ll.h index 7ec9e94841..6ab224a6c7 100644 --- a/components/hal/esp32s2/include/hal/i2s_ll.h +++ b/components/hal/esp32s2/include/hal/i2s_ll.h @@ -42,6 +42,8 @@ extern "C" { #define I2S_LL_TX_EVENT_MASK I2S_LL_EVENT_TX_EOF #define I2S_LL_RX_EVENT_MASK I2S_LL_EVENT_RX_EOF +#define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz + /* I2S clock configuration structure */ typedef struct { uint16_t mclk_div; // I2S module clock divider, Fmclk = Fsclk /(mclk_div+b/a) diff --git a/components/hal/esp32s3/include/hal/i2s_ll.h b/components/hal/esp32s3/include/hal/i2s_ll.h index 0f35ff0be3..d9c0cf26f2 100644 --- a/components/hal/esp32s3/include/hal/i2s_ll.h +++ b/components/hal/esp32s3/include/hal/i2s_ll.h @@ -33,6 +33,8 @@ extern "C" { #define I2S_LL_MCLK_DIVIDER_BIT_WIDTH (9) #define I2S_LL_MCLK_DIVIDER_MAX ((1 << I2S_LL_MCLK_DIVIDER_BIT_WIDTH) - 1) +#define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz + /* I2S clock configuration structure */ typedef struct { uint16_t mclk_div; // I2S module clock divider, Fmclk = Fsclk /(mclk_div+b/a) diff --git a/components/soc/esp32/include/soc/Kconfig.soc_caps.in b/components/soc/esp32/include/soc/Kconfig.soc_caps.in index 70d1efe7d2..30e5a3df62 100644 --- a/components/soc/esp32/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32/include/soc/Kconfig.soc_caps.in @@ -299,6 +299,10 @@ config SOC_I2S_SUPPORTS_APLL bool default y +config SOC_I2S_SUPPORTS_PLL_F160M + bool + default y + config SOC_I2S_SUPPORTS_PDM bool default y diff --git a/components/soc/esp32/include/soc/clk_tree_defs.h b/components/soc/esp32/include/soc/clk_tree_defs.h index 1a599c62ff..3069114b12 100644 --- a/components/soc/esp32/include/soc/clk_tree_defs.h +++ b/components/soc/esp32/include/soc/clk_tree_defs.h @@ -244,15 +244,15 @@ typedef enum { /** * @brief Array initializer for all supported clock sources of I2S */ -#define SOC_I2S_CLKS {SOC_MOD_CLK_PLL_D2, SOC_MOD_CLK_APLL} +#define SOC_I2S_CLKS {SOC_MOD_CLK_PLL_F160M, SOC_MOD_CLK_APLL} /** * @brief I2S clock source enum * */ typedef enum { - I2S_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_D2, /*!< Select PLL_D2 as the default source clock */ - I2S_CLK_SRC_PLL_160M = SOC_MOD_CLK_PLL_D2, /*!< Select PLL_D2 as the source clock */ + I2S_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F160M, /*!< Select PLL_F160M as the default source clock */ + I2S_CLK_SRC_PLL_160M = SOC_MOD_CLK_PLL_F160M, /*!< Select PLL_F160M as the source clock */ I2S_CLK_SRC_APLL = SOC_MOD_CLK_APLL, /*!< Select APLL as the source clock */ } soc_periph_i2s_clk_src_t; diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index f5958086c4..7b72bf6dd8 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -185,6 +185,7 @@ #define SOC_I2S_NUM (2U) #define SOC_I2S_HW_VERSION_1 (1) #define SOC_I2S_SUPPORTS_APLL (1) +#define SOC_I2S_SUPPORTS_PLL_F160M (1) #define SOC_I2S_SUPPORTS_PDM (1) #define SOC_I2S_SUPPORTS_PDM_TX (1) #define SOC_I2S_PDM_MAX_TX_LINES (1U) diff --git a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in index d328f4a92c..cfb7b79d42 100644 --- a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in @@ -375,6 +375,10 @@ config SOC_I2S_SUPPORTS_XTAL bool default y +config SOC_I2S_SUPPORTS_PLL_F160M + bool + default y + config SOC_I2S_SUPPORTS_PCM bool default y diff --git a/components/soc/esp32c3/include/soc/soc_caps.h b/components/soc/esp32c3/include/soc/soc_caps.h index 9c79e1895d..604ced866c 100644 --- a/components/soc/esp32c3/include/soc/soc_caps.h +++ b/components/soc/esp32c3/include/soc/soc_caps.h @@ -184,6 +184,7 @@ #define SOC_I2S_NUM (1) #define SOC_I2S_HW_VERSION_2 (1) #define SOC_I2S_SUPPORTS_XTAL (1) +#define SOC_I2S_SUPPORTS_PLL_F160M (1) #define SOC_I2S_SUPPORTS_PCM (1) #define SOC_I2S_SUPPORTS_PDM (1) #define SOC_I2S_SUPPORTS_PDM_TX (1) diff --git a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in index 244bd789a6..6e587ae4d4 100644 --- a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in @@ -367,6 +367,10 @@ config SOC_I2S_SUPPORTS_XTAL bool default y +config SOC_I2S_SUPPORTS_PLL_F160M + bool + default y + config SOC_I2S_SUPPORTS_PCM bool default y diff --git a/components/soc/esp32c6/include/soc/soc_caps.h b/components/soc/esp32c6/include/soc/soc_caps.h index 0f9d99c411..71acc05436 100644 --- a/components/soc/esp32c6/include/soc/soc_caps.h +++ b/components/soc/esp32c6/include/soc/soc_caps.h @@ -205,6 +205,7 @@ #define SOC_I2S_NUM (1) #define SOC_I2S_HW_VERSION_2 (1) #define SOC_I2S_SUPPORTS_XTAL (1) +#define SOC_I2S_SUPPORTS_PLL_F160M (1) #define SOC_I2S_SUPPORTS_PCM (1) #define SOC_I2S_SUPPORTS_PDM (1) #define SOC_I2S_SUPPORTS_PDM_TX (1) diff --git a/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in index 3edca105ed..bd2e0674cc 100644 --- a/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in @@ -351,6 +351,10 @@ config SOC_I2S_SUPPORTS_XTAL bool default y +config SOC_I2S_SUPPORTS_PLL_F96M + bool + default y + config SOC_I2S_SUPPORTS_PCM bool default y diff --git a/components/soc/esp32h4/include/soc/soc_caps.h b/components/soc/esp32h4/include/soc/soc_caps.h index d7772eeed4..c209d12f58 100644 --- a/components/soc/esp32h4/include/soc/soc_caps.h +++ b/components/soc/esp32h4/include/soc/soc_caps.h @@ -191,6 +191,7 @@ #define SOC_I2S_NUM (1) #define SOC_I2S_HW_VERSION_2 (1) #define SOC_I2S_SUPPORTS_XTAL (1) +#define SOC_I2S_SUPPORTS_PLL_F96M (1) #define SOC_I2S_SUPPORTS_PCM (1) #define SOC_I2S_SUPPORTS_PDM (1) #define SOC_I2S_SUPPORTS_PDM_TX (1) diff --git a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in index 35e159f3b3..469453abce 100644 --- a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in @@ -363,6 +363,10 @@ config SOC_I2S_SUPPORTS_APLL bool default y +config SOC_I2S_SUPPORTS_PLL_F160M + bool + default y + config SOC_I2S_SUPPORTS_DMA_EQUAL bool default y diff --git a/components/soc/esp32s2/include/soc/soc_caps.h b/components/soc/esp32s2/include/soc/soc_caps.h index 9c1c3ee293..683e6f681e 100644 --- a/components/soc/esp32s2/include/soc/soc_caps.h +++ b/components/soc/esp32s2/include/soc/soc_caps.h @@ -181,6 +181,7 @@ #define SOC_I2S_NUM (1U) #define SOC_I2S_HW_VERSION_1 (1) #define SOC_I2S_SUPPORTS_APLL (1) +#define SOC_I2S_SUPPORTS_PLL_F160M (1) #define SOC_I2S_SUPPORTS_DMA_EQUAL (1) #define SOC_I2S_SUPPORTS_LCD_CAMERA (1) #define SOC_I2S_APLL_MIN_FREQ (250000000) diff --git a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in index b2bdf24ccf..181410cdbb 100644 --- a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in @@ -419,6 +419,10 @@ config SOC_I2S_SUPPORTS_XTAL bool default y +config SOC_I2S_SUPPORTS_PLL_F160M + bool + default y + config SOC_I2S_SUPPORTS_PCM bool default y diff --git a/components/soc/esp32s3/include/soc/soc_caps.h b/components/soc/esp32s3/include/soc/soc_caps.h index de2b9abf02..d7864fa6e2 100644 --- a/components/soc/esp32s3/include/soc/soc_caps.h +++ b/components/soc/esp32s3/include/soc/soc_caps.h @@ -185,6 +185,7 @@ #define SOC_I2S_NUM (2) #define SOC_I2S_HW_VERSION_2 (1) #define SOC_I2S_SUPPORTS_XTAL (1) +#define SOC_I2S_SUPPORTS_PLL_F160M (1) #define SOC_I2S_SUPPORTS_PCM (1) #define SOC_I2S_SUPPORTS_PDM (1) #define SOC_I2S_SUPPORTS_PDM_TX (1)