diff --git a/components/esp_driver_i2s/i2s_common.c b/components/esp_driver_i2s/i2s_common.c index 27042989ae..1bd20ceb9e 100644 --- a/components/esp_driver_i2s/i2s_common.c +++ b/components/esp_driver_i2s/i2s_common.c @@ -23,6 +23,7 @@ #include "soc/i2s_periph.h" #include "soc/soc_caps.h" +#include "soc/soc_caps_full.h" #include "hal/i2s_hal.h" #include "hal/hal_utils.h" #include "hal/dma_types.h" @@ -31,7 +32,7 @@ #include "hal/cache_ll.h" #endif -#if SOC_I2S_SUPPORTS_ADC_DAC +#if SOC_MODULE_SUPPORT(I2S, ADC_DAC) #include "hal/adc_ll.h" #endif #if SOC_I2S_SUPPORTS_APLL @@ -41,7 +42,7 @@ #include "esp_private/i2s_platform.h" #include "esp_private/esp_clk.h" -#if SOC_I2S_SUPPORT_SLEEP_RETENTION +#if SOC_HAS(PAU) #include "esp_private/sleep_retention.h" #endif @@ -226,13 +227,13 @@ static esp_err_t i2s_destroy_controller_obj(i2s_controller_t **i2s_obj) * @param id i2s port id * @param search_reverse reverse the sequence of port acquirement * set false to acquire from I2S_NUM_0 first - * set true to acquire from SOC_I2S_NUM - 1 first + * set true to acquire from SOC_I2S_ATTR(INST_NUM) - 1 first * @return * - pointer of acquired i2s controller object */ static i2s_controller_t *i2s_acquire_controller_obj(int id) { - if (id < 0 || id >= SOC_I2S_NUM) { + if (id < 0 || id >= SOC_I2S_ATTR(INST_NUM)) { return NULL; } /* pre-alloc controller object */ @@ -254,7 +255,7 @@ static i2s_controller_t *i2s_acquire_controller_obj(int id) i2s_obj = pre_alloc; g_i2s.controller[id] = i2s_obj; portEXIT_CRITICAL(&g_i2s.spinlock); -#if SOC_I2S_SUPPORTS_ADC_DAC +#if SOC_MODULE_SUPPORT(I2S, ADC_DAC) if (id == I2S_NUM_0) { adc_ll_digi_set_data_source(0); } @@ -753,18 +754,18 @@ static void i2s_dma_tx_callback(void *arg) esp_err_t i2s_init_dma_intr(i2s_chan_handle_t handle, int intr_flag) { esp_err_t ret = ESP_OK; - i2s_port_t port_id = handle->controller->id; - ESP_RETURN_ON_FALSE((port_id >= 0) && (port_id < SOC_I2S_NUM), ESP_ERR_INVALID_ARG, TAG, "invalid handle"); + int port_id = handle->controller->id; + ESP_RETURN_ON_FALSE((port_id >= 0) && (port_id < SOC_I2S_ATTR(INST_NUM)), ESP_ERR_INVALID_ARG, TAG, "invalid handle"); /* Set GDMA trigger module */ gdma_trigger_t trig = {.periph = GDMA_TRIG_PERIPH_I2S}; switch (port_id) { -#if SOC_I2S_NUM > 2 +#if SOC_I2S_ATTR(INST_NUM) > 2 case I2S_NUM_2: trig.instance_id = SOC_GDMA_TRIG_PERIPH_I2S2; break; #endif -#if SOC_I2S_NUM > 1 +#if SOC_I2S_ATTR(INST_NUM) > 1 case I2S_NUM_1: trig.instance_id = SOC_GDMA_TRIG_PERIPH_I2S1; break; @@ -824,8 +825,8 @@ err1: esp_err_t i2s_init_dma_intr(i2s_chan_handle_t handle, int intr_flag) { esp_err_t ret = ESP_OK; - i2s_port_t port_id = handle->controller->id; - ESP_RETURN_ON_FALSE((port_id >= 0) && (port_id < SOC_I2S_NUM), ESP_ERR_INVALID_ARG, TAG, "invalid handle"); + int port_id = handle->controller->id; + ESP_RETURN_ON_FALSE((port_id >= 0) && (port_id < SOC_I2S_ATTR(INST_NUM)), ESP_ERR_INVALID_ARG, TAG, "invalid handle"); intr_flag |= handle->intr_prio_flags; /* Initialize I2S module interrupt */ if (handle->dir == I2S_DIR_TX) { @@ -906,7 +907,7 @@ void i2s_gpio_loopback_set(i2s_chan_handle_t handle, int gpio, uint32_t out_sig_ } } -esp_err_t i2s_check_set_mclk(i2s_chan_handle_t handle, i2s_port_t id, int gpio_num, i2s_clock_src_t clk_src, bool is_invert) +esp_err_t i2s_check_set_mclk(i2s_chan_handle_t handle, int id, int gpio_num, i2s_clock_src_t clk_src, bool is_invert) { if (gpio_num == (int)I2S_GPIO_UNUSED) { return ESP_OK; @@ -947,16 +948,16 @@ esp_err_t i2s_new_channel(const i2s_chan_config_t *chan_cfg, i2s_chan_handle_t * /* Parameter validity check */ I2S_NULL_POINTER_CHECK(TAG, chan_cfg); I2S_NULL_POINTER_CHECK(TAG, tx_handle || rx_handle); - ESP_RETURN_ON_FALSE(chan_cfg->id < SOC_I2S_NUM || chan_cfg->id == I2S_NUM_AUTO, ESP_ERR_INVALID_ARG, TAG, "invalid I2S port id"); + ESP_RETURN_ON_FALSE((chan_cfg->id >= 0 && chan_cfg->id < SOC_I2S_ATTR(INST_NUM)) || chan_cfg->id == I2S_NUM_AUTO, ESP_ERR_INVALID_ARG, TAG, "invalid I2S port id"); ESP_RETURN_ON_FALSE(chan_cfg->dma_desc_num >= 2, ESP_ERR_INVALID_ARG, TAG, "there should be at least 2 DMA buffers"); ESP_RETURN_ON_FALSE(chan_cfg->intr_priority >= 0 && chan_cfg->intr_priority <= 7, ESP_ERR_INVALID_ARG, TAG, "intr_priority should be within 0~7"); -#if !SOC_I2S_SUPPORT_SLEEP_RETENTION +#if !SOC_HAS(PAU) ESP_RETURN_ON_FALSE(!chan_cfg->allow_pd, ESP_ERR_NOT_SUPPORTED, TAG, "register back up is not supported"); #endif esp_err_t ret = ESP_OK; i2s_controller_t *i2s_obj = NULL; - i2s_port_t id = chan_cfg->id; + int id = chan_cfg->id; bool channel_found = false; uint8_t chan_search_mask = 0; chan_search_mask |= tx_handle ? I2S_DIR_TX : 0; @@ -965,7 +966,7 @@ esp_err_t i2s_new_channel(const i2s_chan_config_t *chan_cfg, i2s_chan_handle_t * /* Channel will be registered to one i2s port automatically if id is I2S_NUM_AUTO * Otherwise, the channel will be registered to the specific port. */ if (id == I2S_NUM_AUTO) { - for (int i = 0; i < SOC_I2S_NUM && !channel_found; i++) { + for (int i = 0; i < SOC_I2S_ATTR(INST_NUM) && !channel_found; i++) { i2s_obj = i2s_acquire_controller_obj(i); if (!i2s_obj) { continue; @@ -1022,7 +1023,7 @@ esp_err_t i2s_new_channel(const i2s_chan_config_t *chan_cfg, i2s_chan_handle_t * err: /* if the controller object has no channel, find the corresponding global object and destroy it */ if (i2s_obj != NULL && i2s_obj->rx_chan == NULL && i2s_obj->tx_chan == NULL) { - for (int i = 0; i < SOC_I2S_NUM; i++) { + for (int i = 0; i < SOC_I2S_ATTR(INST_NUM); i++) { if (i2s_obj == g_i2s.controller[i]) { i2s_destroy_controller_obj(&g_i2s.controller[i]); break; @@ -1133,7 +1134,7 @@ esp_err_t i2s_channel_get_info(i2s_chan_handle_t handle, i2s_chan_info_t *chan_i I2S_NULL_POINTER_CHECK(TAG, chan_info); /* Find whether the handle is a registered i2s handle or still available */ - for (int i = 0; i < SOC_I2S_NUM; i++) { + for (int i = 0; i < SOC_I2S_ATTR(INST_NUM); i++) { if (g_i2s.controller[i] != NULL) { if (g_i2s.controller[i]->tx_chan == handle || g_i2s.controller[i]->rx_chan == handle) { diff --git a/components/esp_driver_i2s/i2s_platform.c b/components/esp_driver_i2s/i2s_platform.c index 7c5757e0bd..7baa7903ad 100644 --- a/components/esp_driver_i2s/i2s_platform.c +++ b/components/esp_driver_i2s/i2s_platform.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,8 +16,8 @@ static const char *TAG = "i2s_platform"; */ i2s_platform_t g_i2s = { .spinlock = (portMUX_TYPE)portMUX_INITIALIZER_UNLOCKED, - .controller[0 ...(SOC_I2S_NUM - 1)] = NULL, // groups will be lazy installed - .comp_name[0 ...(SOC_I2S_NUM - 1)] = NULL, + .controller[0 ...(SOC_I2S_ATTR(INST_NUM) - 1)] = NULL, // groups will be lazy installed + .comp_name[0 ...(SOC_I2S_ATTR(INST_NUM) - 1)] = NULL, #if SOC_LP_I2S_SUPPORTED .lp_controller[0 ...(SOC_LP_I2S_NUM - 1)] = NULL, .lp_comp_name[0 ...(SOC_LP_I2S_NUM - 1)] = NULL, @@ -34,7 +34,7 @@ esp_err_t i2s_platform_acquire_occupation(i2s_ctlr_t type, int id, const char *c { esp_err_t ret = ESP_OK; const char *occupied_comp = NULL; - ESP_RETURN_ON_FALSE(id < SOC_I2S_NUM, ESP_ERR_INVALID_ARG, TAG, "invalid i2s port id"); + ESP_RETURN_ON_FALSE(id < SOC_I2S_ATTR(INST_NUM), ESP_ERR_INVALID_ARG, TAG, "invalid i2s port id"); if (type == I2S_CTLR_HP) { portENTER_CRITICAL(&g_i2s.spinlock); @@ -79,7 +79,7 @@ esp_err_t i2s_platform_acquire_occupation(i2s_ctlr_t type, int id, const char *c esp_err_t i2s_platform_release_occupation(i2s_ctlr_t type, int id) { esp_err_t ret = ESP_OK; - ESP_RETURN_ON_FALSE(id < SOC_I2S_NUM, ESP_ERR_INVALID_ARG, TAG, "invalid i2s port id"); + ESP_RETURN_ON_FALSE(id < SOC_I2S_ATTR(INST_NUM), ESP_ERR_INVALID_ARG, TAG, "invalid i2s port id"); if (type == I2S_CTLR_HP) { portENTER_CRITICAL(&g_i2s.spinlock); diff --git a/components/esp_driver_i2s/i2s_private.h b/components/esp_driver_i2s/i2s_private.h index b734f650d8..5005816c57 100644 --- a/components/esp_driver_i2s/i2s_private.h +++ b/components/esp_driver_i2s/i2s_private.h @@ -13,6 +13,7 @@ #include "freertos/queue.h" #include "soc/lldesc.h" #include "soc/soc_caps.h" +#include "soc/soc_caps_full.h" #include "hal/i2s_hal.h" #include "hal/lp_i2s_hal.h" #if SOC_LP_I2S_SUPPORTED @@ -27,7 +28,7 @@ #endif #include "esp_private/periph_ctrl.h" #include "esp_private/esp_gpio_reserve.h" -#if SOC_I2S_SUPPORT_SLEEP_RETENTION +#if SOC_HAS(PAU) #include "esp_private/sleep_retention.h" #endif #include "esp_pm.h" @@ -61,7 +62,7 @@ extern "C" { #define I2S_RCC_ATOMIC() #endif -#define I2S_USE_RETENTION_LINK (SOC_I2S_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP) +#define I2S_USE_RETENTION_LINK (SOC_HAS(PAU) && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP) #define I2S_NULL_POINTER_CHECK(tag, p) ESP_RETURN_ON_FALSE((p), ESP_ERR_INVALID_ARG, tag, "input parameter '"#p"' is NULL") #define MAX(a, b) ((a) > (b) ? (a) : (b)) @@ -131,14 +132,14 @@ typedef struct { * @note Both i2s rx and tx channel are under its control */ typedef struct { - i2s_port_t id; /*!< i2s port id */ + int id; /*!< i2s port id */ i2s_hal_context_t hal; /*!< hal context */ uint32_t chan_occupancy; /*!< channel occupancy (rx/tx) */ bool full_duplex; /*!< is full_duplex */ i2s_chan_handle_t tx_chan; /*!< tx channel handler */ i2s_chan_handle_t rx_chan; /*!< rx channel handler */ _lock_t mutex; /*!< mutex for controller */ -#if SOC_I2S_SUPPORT_SLEEP_RETENTION +#if SOC_HAS(PAU) sleep_retention_module_t slp_retention_mod; /*!< Sleep retention module */ bool retention_link_created; /*!< Whether the retention link is created */ #endif @@ -223,11 +224,11 @@ struct lp_i2s_channel_obj_t { */ typedef struct { portMUX_TYPE spinlock; /*!< Platform level lock */ - i2s_controller_t *controller[SOC_I2S_NUM]; /*!< Controller object */ - const char *comp_name[SOC_I2S_NUM]; /*!< The component name that occupied i2s controller */ + i2s_controller_t *controller[SOC_I2S_ATTR(INST_NUM)]; /*!< Controller object */ + const char *comp_name[SOC_I2S_ATTR(INST_NUM)]; /*!< The component name that occupied i2s controller */ #if SOC_LP_I2S_SUPPORTED lp_i2s_controller_t *lp_controller[SOC_LP_I2S_NUM]; /*!< LP controller object*/ - const char *lp_comp_name[SOC_I2S_NUM]; /*!< The component name that occupied lp i2s controller */ + const char *lp_comp_name[SOC_I2S_ATTR(INST_NUM)]; /*!< The component name that occupied lp i2s controller */ #endif } i2s_platform_t; @@ -312,7 +313,7 @@ void i2s_gpio_check_and_set(i2s_chan_handle_t handle, int gpio, uint32_t signal_ * - ESP_OK Set mclk output gpio success * - ESP_ERR_INVALID_ARG Invalid GPIO number */ -esp_err_t i2s_check_set_mclk(i2s_chan_handle_t handle, i2s_port_t id, int gpio_num, i2s_clock_src_t clk_src, bool is_invert); +esp_err_t i2s_check_set_mclk(i2s_chan_handle_t handle, int id, int gpio_num, i2s_clock_src_t clk_src, bool is_invert); /** * @brief Attach data out signal and data in signal to a same gpio diff --git a/components/esp_driver_i2s/include/driver/i2s_common.h b/components/esp_driver_i2s/include/driver/i2s_common.h index 6cf5381343..70158d1e7c 100644 --- a/components/esp_driver_i2s/include/driver/i2s_common.h +++ b/components/esp_driver_i2s/include/driver/i2s_common.h @@ -57,7 +57,7 @@ typedef struct { * @brief I2S controller channel configuration */ typedef struct { - i2s_port_t id; /*!< I2S port id */ + int id; /*!< I2S port id */ i2s_role_t role; /*!< I2S role, I2S_ROLE_MASTER or I2S_ROLE_SLAVE */ /* DMA configurations */ @@ -85,7 +85,7 @@ typedef struct { * @brief I2S channel information */ typedef struct { - i2s_port_t id; /*!< I2S port id */ + int id; /*!< I2S port id */ i2s_role_t role; /*!< I2S role, I2S_ROLE_MASTER or I2S_ROLE_SLAVE */ i2s_dir_t dir; /*!< I2S channel direction */ i2s_comm_mode_t mode; /*!< I2S channel communication mode */ diff --git a/components/esp_driver_i2s/include/driver/i2s_types.h b/components/esp_driver_i2s/include/driver/i2s_types.h index 80eac1e6ff..f5998cdb37 100644 --- a/components/esp_driver_i2s/include/driver/i2s_types.h +++ b/components/esp_driver_i2s/include/driver/i2s_types.h @@ -15,19 +15,10 @@ extern "C" { #endif -/** - * @brief I2S controller port number, the max port number is (SOC_I2S_NUM -1). - */ -typedef enum { - I2S_NUM_0 = 0, /*!< I2S controller port 0 */ -#if SOC_I2S_NUM > 1 - I2S_NUM_1 = 1, /*!< I2S controller port 1 */ -#endif -#if SOC_I2S_NUM > 2 - I2S_NUM_2 = 2, /*!< I2S controller port 2 */ -#endif - I2S_NUM_AUTO, /*!< Select whichever port is available */ -} i2s_port_t; +#define I2S_NUM_0 0 /*!< I2S controller port 0 */ +#define I2S_NUM_1 1 /*!< I2S controller port 1 */ +#define I2S_NUM_2 2 /*!< I2S controller port 2 */ +#define I2S_NUM_AUTO -1 /*!< Select an available port automatically */ /** * @brief I2S controller communication mode diff --git a/components/esp_driver_i2s/test_apps/i2s/main/test_i2s.c b/components/esp_driver_i2s/test_apps/i2s/main/test_i2s.c index 115606d69d..77a2770296 100644 --- a/components/esp_driver_i2s/test_apps/i2s/main/test_i2s.c +++ b/components/esp_driver_i2s/test_apps/i2s/main/test_i2s.c @@ -55,7 +55,7 @@ static void i2s_test_io_config(int mode) gpio_set_direction(DATA_OUT_IO, GPIO_MODE_INPUT_OUTPUT); switch (mode) { -#if SOC_I2S_NUM > 1 +#if SOC_I2S_ATTR(INST_NUM) > 1 case I2S_TEST_MODE_SLAVE_TO_MASTER: { esp_rom_gpio_connect_out_signal(MASTER_BCK_IO, i2s_periph_signal[0].m_rx_bck_sig, 0, 0); esp_rom_gpio_connect_in_signal(MASTER_BCK_IO, i2s_periph_signal[1].s_tx_bck_sig, 0); @@ -169,14 +169,14 @@ TEST_CASE("I2S_basic_channel_allocation_reconfig_deleting_test", "[i2s]") /* Exhaust test */ std_cfg.gpio_cfg.mclk = -1; - i2s_chan_handle_t tx_ex[SOC_I2S_NUM] = {}; - for (int i = 0; i < SOC_I2S_NUM; i++) { + i2s_chan_handle_t tx_ex[SOC_I2S_ATTR(INST_NUM)] = {}; + for (int i = 0; i < SOC_I2S_ATTR(INST_NUM); i++) { TEST_ESP_OK(i2s_new_channel(&chan_cfg, &tx_ex[i], NULL)); TEST_ESP_OK(i2s_channel_init_std_mode(tx_ex[i], &std_cfg)); TEST_ESP_OK(i2s_channel_enable(tx_ex[i])); } TEST_ESP_ERR(ESP_ERR_NOT_FOUND, i2s_new_channel(&chan_cfg, &tx_handle, NULL)); - for (int i = 0; i < SOC_I2S_NUM; i++) { + for (int i = 0; i < SOC_I2S_ATTR(INST_NUM); i++) { TEST_ESP_OK(i2s_channel_disable(tx_ex[i])); TEST_ESP_OK(i2s_del_channel(tx_ex[i])); } @@ -741,7 +741,7 @@ TEST_CASE("I2S_loopback_test", "[i2s]") TEST_ESP_OK(i2s_del_channel(rx_handle)); } -#if SOC_I2S_NUM > 1 && !CONFIG_ESP32P4_SELECTS_REV_LESS_V3 +#if SOC_I2S_ATTR(INST_NUM) > 1 && !CONFIG_ESP32P4_SELECTS_REV_LESS_V3 TEST_CASE("I2S_master_write_slave_read_test", "[i2s]") { i2s_chan_handle_t tx_handle; @@ -856,11 +856,11 @@ static void i2s_test_common_sample_rate(i2s_chan_handle_t rx_chan, i2s_std_clk_c }; int real_pulse = 0; int case_cnt = sizeof(test_freq) / sizeof(uint32_t); -#if SOC_I2S_SUPPORTS_PLL_F96M +#if I2S_LL_DEFAULT_CLK_FREQ == 96000000 // 196000 Hz sample rate doesn't support on PLL_96M target case_cnt = 15; #endif -#if SOC_I2S_SUPPORTS_XTAL +#if I2S_LL_SUPPORT_XTAL // Can't support a very high sample rate while using XTAL as clock source if (clk_cfg->clk_src == I2S_CLK_SRC_XTAL) { case_cnt = 10; @@ -911,7 +911,7 @@ TEST_CASE("I2S_default_PLL_clock_test", "[i2s]") std_cfg.clk_cfg.clk_src = I2S_LL_DEFAULT_CLK_SRC; #endif i2s_test_common_sample_rate(rx_handle, &std_cfg.clk_cfg); -#if SOC_I2S_SUPPORTS_XTAL +#if I2S_LL_SUPPORT_XTAL std_cfg.clk_cfg.clk_src = I2S_CLK_SRC_XTAL; i2s_test_common_sample_rate(rx_handle, &std_cfg.clk_cfg); #endif diff --git a/components/esp_driver_i2s/test_apps/i2s/main/test_i2s_sleep.c b/components/esp_driver_i2s/test_apps/i2s/main/test_i2s_sleep.c index 2a0a208de0..0424a7c6d7 100644 --- a/components/esp_driver_i2s/test_apps/i2s/main/test_i2s_sleep.c +++ b/components/esp_driver_i2s/test_apps/i2s/main/test_i2s_sleep.c @@ -13,13 +13,14 @@ #include "driver/i2s_std.h" #include "driver/uart.h" #include "soc/i2s_struct.h" +#include "soc/soc_caps_full.h" #include "esp_sleep.h" #include "esp_private/sleep_cpu.h" #include "esp_private/esp_sleep_internal.h" #include "esp_private/esp_pmu.h" #include "../../test_inc/test_i2s.h" -#define TEST_I2S_PD_SLEEP (SOC_I2S_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP) +#define TEST_I2S_PD_SLEEP (SOC_HAS(PAU) && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP) extern void i2s_read_write_test(i2s_chan_handle_t tx_chan, i2s_chan_handle_t rx_chan); @@ -42,7 +43,7 @@ static void s_test_i2s_enter_light_sleep(int sec, bool allow_power_down) printf("Woke up from light sleep\n"); TEST_ASSERT_EQUAL(0, sleep_ctx.sleep_request_result); -#if SOC_I2S_SUPPORT_SLEEP_RETENTION && !SOC_PM_TOP_PD_NOT_ALLOWED +#if SOC_HAS(PAU) && !SOC_PM_TOP_PD_NOT_ALLOWED // check if the power domain also is powered down TEST_ASSERT_EQUAL(allow_power_down ? PMU_SLEEP_PD_TOP : 0, (sleep_ctx.sleep_flags) & PMU_SLEEP_PD_TOP); #endif diff --git a/components/esp_hw_support/sleep_system_peripheral.c b/components/esp_hw_support/sleep_system_peripheral.c index 712be622b6..21b9b3daf7 100644 --- a/components/esp_hw_support/sleep_system_peripheral.c +++ b/components/esp_hw_support/sleep_system_peripheral.c @@ -237,15 +237,15 @@ bool peripheral_domain_pd_allowed(void) # endif /* SOC_AXI_GDMA_SUPPORTED */ #endif /* SOC_GDMA_SUPPORT_SLEEP_RETENTION */ -#if SOC_I2S_SUPPORT_SLEEP_RETENTION +#if SOC_HAS(PAU) mask.bitmap[SLEEP_RETENTION_MODULE_I2S0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_I2S0 % 32); -# if (SOC_I2S_NUM > 1) +# if (SOC_MODULE_ATTR(I2S, INST_NUM) > 1) mask.bitmap[SLEEP_RETENTION_MODULE_I2S1 >> 5] |= BIT(SLEEP_RETENTION_MODULE_I2S1 % 32); # endif -# if (SOC_I2S_NUM > 2) +# if (SOC_MODULE_ATTR(I2S, INST_NUM) > 2) mask.bitmap[SLEEP_RETENTION_MODULE_I2S2 >> 5] |= BIT(SLEEP_RETENTION_MODULE_I2S2 % 32); # endif -#endif /* SOC_I2S_SUPPORT_SLEEP_RETENTION */ +#endif /* SOC_HAS(PAU) */ #if SOC_I2C_SUPPORT_SLEEP_RETENTION mask.bitmap[SLEEP_RETENTION_MODULE_I2C0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_I2C0 % 32); diff --git a/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c b/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c index e38d1a218c..891944d664 100644 --- a/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c +++ b/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c @@ -100,7 +100,7 @@ esp_err_t esp_lcd_new_i80_bus(const esp_lcd_i80_bus_config_t *bus_config, esp_lc ESP_GOTO_ON_FALSE(bus_config->bus_width == 8 || bus_config->bus_width == 16, ESP_ERR_INVALID_ARG, err, TAG, "invalid bus width:%d", bus_config->bus_width); size_t max_transfer_bytes = (bus_config->max_transfer_bytes + 3) & ~0x03; // align up to 4 bytes -#if SOC_I2S_TRANS_SIZE_ALIGN_WORD +#if SOC_I2S_ATTR(TRANS_SIZE_ALIGN_WORD) // double the size of the internal DMA buffer if bus_width is 8, // because one I2S FIFO (4 bytes) will only contain two bytes of valid data max_transfer_bytes = max_transfer_bytes * 16 / bus_config->bus_width + 4; @@ -120,13 +120,13 @@ esp_err_t esp_lcd_new_i80_bus(const esp_lcd_i80_bus_config_t *bus_config, esp_lc ESP_GOTO_ON_ERROR(gdma_new_link_list(&dma_link_config, &bus->dma_link), err, TAG, "create DMA link list failed"); bus->bus_id = -1; bus->max_transfer_bytes = max_transfer_bytes; -#if SOC_I2S_TRANS_SIZE_ALIGN_WORD +#if SOC_I2S_ATTR(TRANS_SIZE_ALIGN_WORD) // transform format for LCD commands, parameters and color data, so we need a big buffer bus->format_buffer = heap_caps_calloc(1, max_transfer_bytes, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT | MALLOC_CAP_DMA); #else // only transform format for LCD parameters, buffer size depends on specific LCD, set at compile time bus->format_buffer = heap_caps_calloc(1, LCD_I80_IO_FORMAT_BUF_SIZE, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT | MALLOC_CAP_DMA); -#endif // SOC_I2S_TRANS_SIZE_ALIGN_WORD +#endif // SOC_I2S_ATTR(TRANS_SIZE_ALIGN_WORD) ESP_GOTO_ON_FALSE(bus->format_buffer, ESP_ERR_NO_MEM, err, TAG, "no mem for format buffer"); // LCD mode can't work with other modes at the same time, we need to register the driver object to the I2S platform int bus_id = -1; @@ -171,7 +171,7 @@ esp_err_t esp_lcd_new_i80_bus(const esp_lcd_i80_bus_config_t *bus_config, esp_lc i2s_ll_tx_select_std_slot(bus->hal.dev, I2S_STD_SLOT_BOTH, true); // copy mono bus->bus_width = bus_config->bus_width; i2s_ll_tx_enable_right_first(bus->hal.dev, true); -#if SOC_I2S_SUPPORTS_DMA_EQUAL +#if SOC_MODULE_SUPPORT(I2S, DMA_EQUAL) i2s_ll_tx_enable_dma_equal(bus->hal.dev, true); #endif // enable trans done interrupt @@ -372,7 +372,7 @@ static void i2s_lcd_prepare_cmd_buffer(lcd_i80_trans_descriptor_t *trans_desc, c int end = i80_device->lcd_cmd_bits / 8 - 1; lcd_com_reverse_buffer_bytes(from, start, end); } -#if SOC_I2S_TRANS_SIZE_ALIGN_WORD +#if SOC_I2S_ATTR(TRANS_SIZE_ALIGN_WORD) uint8_t *to = bus->format_buffer; int cmd_cycle = i80_device->lcd_cmd_bits / bus->bus_width; if (cmd_cycle * bus->bus_width < i80_device->lcd_cmd_bits) { @@ -410,7 +410,7 @@ static void i2s_lcd_prepare_param_buffer(lcd_i80_trans_descriptor_t *trans_desc, lcd_com_reverse_buffer_bytes(from, start, end); } } -#if SOC_I2S_TRANS_SIZE_ALIGN_WORD +#if SOC_I2S_ATTR(TRANS_SIZE_ALIGN_WORD) uint8_t *to = bus->format_buffer; int param_cycle = i80_device->lcd_param_bits / bus->bus_width; if (param_cycle * bus->bus_width < i80_device->lcd_param_bits) { @@ -452,7 +452,7 @@ static void i2s_lcd_prepare_param_buffer(lcd_i80_trans_descriptor_t *trans_desc, static void i2s_lcd_prepare_color_buffer(lcd_i80_trans_descriptor_t *trans_desc, const void *color, size_t color_size) { -#if SOC_I2S_TRANS_SIZE_ALIGN_WORD +#if SOC_I2S_ATTR(TRANS_SIZE_ALIGN_WORD) lcd_panel_io_i80_t *i80_device = trans_desc->i80_device; esp_lcd_i80_bus_t *bus = i80_device->bus; uint8_t *from = (uint8_t *)color; @@ -509,7 +509,7 @@ static esp_err_t panel_io_i80_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, cons trans_desc->i80_device = next_device; trans_desc->trans_done_cb = NULL; // no callback for command transfer bus->cur_trans = trans_desc; -#if SOC_I2S_TRANS_SIZE_ALIGN_WORD +#if SOC_I2S_ATTR(TRANS_SIZE_ALIGN_WORD) // switch to I2S 32bits mode, one WS cycle <=> one I2S FIFO i2s_ll_tx_set_bits_mod(bus->hal.dev, 32); #endif @@ -589,7 +589,7 @@ static esp_err_t panel_io_i80_tx_color(esp_lcd_panel_io_t *io, int lcd_cmd, cons trans_desc->i80_device = next_device; trans_desc->trans_done_cb = NULL; // no callback for command transfer bus->cur_trans = trans_desc; -#if SOC_I2S_TRANS_SIZE_ALIGN_WORD +#if SOC_I2S_ATTR(TRANS_SIZE_ALIGN_WORD) // switch to I2S 32bits mode, one WS cycle <=> one I2S FIFO i2s_ll_tx_set_bits_mod(bus->hal.dev, 32); #endif @@ -680,10 +680,10 @@ static esp_err_t i2s_lcd_configure_gpio(esp_lcd_i80_bus_handle_t bus, const esp_ for (size_t i = 0; i < bus_config->bus_width; i++) { gpio_func_sel(bus_config->data_gpio_nums[i], PIN_FUNC_GPIO); // the esp_rom_gpio_connect_out_signal function will also help enable the output path properly -#if SOC_I2S_TRANS_SIZE_ALIGN_WORD +#if SOC_I2S_ATTR(TRANS_SIZE_ALIGN_WORD) esp_rom_gpio_connect_out_signal(bus_config->data_gpio_nums[i], lcd_periph_i2s_signals.buses[bus_id].data_sigs[i + 8], false, false); #else - esp_rom_gpio_connect_out_signal(bus_config->data_gpio_nums[i], lcd_periph_i2s_signals.buses[bus_id].data_sigs[i + SOC_I2S_MAX_DATA_WIDTH - bus_config->bus_width], false, false); + esp_rom_gpio_connect_out_signal(bus_config->data_gpio_nums[i], lcd_periph_i2s_signals.buses[bus_id].data_sigs[i + SOC_I2S_ATTR(MAX_DATA_WIDTH) - bus_config->bus_width], false, false); #endif } // WR signal (pclk) @@ -800,7 +800,7 @@ static IRAM_ATTR void i2s_lcd_default_isr_handler(void *args) } }; gdma_link_mount_buffers(bus->dma_link, 0, &mount_config, 1, NULL); -#if SOC_I2S_TRANS_SIZE_ALIGN_WORD +#if SOC_I2S_ATTR(TRANS_SIZE_ALIGN_WORD) // switch to I2S 16bits mode, two WS cycle <=> one I2S FIFO i2s_ll_tx_set_bits_mod(bus->hal.dev, 16); #endif diff --git a/components/hal/esp32/include/hal/i2s_ll.h b/components/hal/esp32/include/hal/i2s_ll.h index 59d686f2c2..2873ceac7a 100644 --- a/components/hal/esp32/include/hal/i2s_ll.h +++ b/components/hal/esp32/include/hal/i2s_ll.h @@ -48,8 +48,7 @@ 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 -#define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT +#define I2S_LL_DEFAULT_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz /** * @brief Enable DMA descriptor owner check diff --git a/components/hal/esp32c3/include/hal/i2s_ll.h b/components/hal/esp32c3/include/hal/i2s_ll.h index 9796935b53..889e2e7729 100644 --- a/components/hal/esp32c3/include/hal/i2s_ll.h +++ b/components/hal/esp32c3/include/hal/i2s_ll.h @@ -35,8 +35,8 @@ extern "C" { #define I2S_LL_CLK_FRAC_DIV_AB_MAX 512 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the a/b register is 9 bit-width #define I2S_LL_SLOT_FRAME_BIT_MAX 128 // Up-to 128 bits in one frame, determined by MAX(half_sample_bits) * 2 -#define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz -#define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT +#define I2S_LL_DEFAULT_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz +#define I2S_LL_SUPPORT_XTAL 1 // Support XTAL as I2S clock source /** diff --git a/components/hal/esp32c5/include/hal/i2s_ll.h b/components/hal/esp32c5/include/hal/i2s_ll.h index c8e7881f0a..6a8053c905 100644 --- a/components/hal/esp32c5/include/hal/i2s_ll.h +++ b/components/hal/esp32c5/include/hal/i2s_ll.h @@ -36,14 +36,12 @@ extern "C" { #define I2S_LL_CLK_FRAC_DIV_N_MAX 256 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the N register is 8 bit-width #define I2S_LL_CLK_FRAC_DIV_AB_MAX 512 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the a/b register is 9 bit-width -/* Add SOC_I2S_TDM_FULL_DATA_WIDTH in the soc_caps to indicate there is no limitation to support full data width (i.e., 16 slots * 32 bits) */ #define I2S_LL_SLOT_FRAME_BIT_MAX 512 // Up-to 512 bits in one frame, determined by MAX(half_sample_bits) * 2 -#define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz -#define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT +#define I2S_LL_DEFAULT_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz #define I2S_LL_ETM_EVENT_TABLE(i2s_port, chan_dir, event) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_EVENT_MAX]){{ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_EVENT_MAX]){{ \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_EVENT_DONE] = I2S0_EVT_RX_DONE, \ [I2S_ETM_EVENT_REACH_THRESH] = I2S0_EVT_X_WORDS_RECEIVED, \ @@ -55,7 +53,7 @@ extern "C" { #define I2S_LL_ETM_TASK_TABLE(i2s_port, chan_dir, task) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_TASK_MAX]){{ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_TASK_MAX]){{ \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_TASK_START] = I2S0_TASK_START_RX, \ [I2S_ETM_TASK_STOP] = I2S0_TASK_STOP_RX, \ diff --git a/components/hal/esp32c6/include/hal/i2s_ll.h b/components/hal/esp32c6/include/hal/i2s_ll.h index e26ba9dcce..a3f80a113d 100644 --- a/components/hal/esp32c6/include/hal/i2s_ll.h +++ b/components/hal/esp32c6/include/hal/i2s_ll.h @@ -36,11 +36,11 @@ extern "C" { #define I2S_LL_CLK_FRAC_DIV_AB_MAX 512 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the a/b register is 9 bit-width #define I2S_LL_SLOT_FRAME_BIT_MAX 128 // Up-to 128 bits in one frame, determined by MAX(half_sample_bits) * 2 -#define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz -#define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT +#define I2S_LL_DEFAULT_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz +#define I2S_LL_SUPPORT_XTAL 1 // Support XTAL as I2S clock source #define I2S_LL_ETM_EVENT_TABLE(i2s_port, chan_dir, event) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_EVENT_MAX]){{ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_EVENT_MAX]){{ \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_EVENT_DONE] = I2S_EVT_RX_DONE, \ [I2S_ETM_EVENT_REACH_THRESH] = I2S_EVT_X_WORDS_RECEIVED, \ @@ -52,7 +52,7 @@ extern "C" { #define I2S_LL_ETM_TASK_TABLE(i2s_port, chan_dir, task) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_TASK_MAX]){{ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_TASK_MAX]){{ \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_TASK_START] = I2S_TASK_START_RX, \ [I2S_ETM_TASK_STOP] = I2S_TASK_STOP_RX, \ diff --git a/components/hal/esp32c61/include/hal/i2s_ll.h b/components/hal/esp32c61/include/hal/i2s_ll.h index 7d11107358..37964f8379 100644 --- a/components/hal/esp32c61/include/hal/i2s_ll.h +++ b/components/hal/esp32c61/include/hal/i2s_ll.h @@ -36,14 +36,13 @@ extern "C" { #define I2S_LL_CLK_FRAC_DIV_N_MAX 256 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the N register is 8 bit-width #define I2S_LL_CLK_FRAC_DIV_AB_MAX 512 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the a/b register is 9 bit-width -/* Add SOC_I2S_TDM_FULL_DATA_WIDTH in the soc_caps to indicate there is no limitation to support full data width (i.e., 16 slots * 32 bits) */ #define I2S_LL_SLOT_FRAME_BIT_MAX 512 // Up-to 512 bits in one frame, determined by MAX(half_sample_bits) * 2 -#define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz -#define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT +#define I2S_LL_DEFAULT_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz +#define I2S_LL_SUPPORT_XTAL 1 // Support XTAL as I2S clock source #define I2S_LL_ETM_EVENT_TABLE(i2s_port, chan_dir, event) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_EVENT_MAX]){{ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_EVENT_MAX]){{ \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_EVENT_DONE] = I2S0_EVT_RX_DONE, \ [I2S_ETM_EVENT_REACH_THRESH] = I2S0_EVT_X_WORDS_RECEIVED, \ @@ -55,7 +54,7 @@ extern "C" { #define I2S_LL_ETM_TASK_TABLE(i2s_port, chan_dir, task) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_TASK_MAX]){{ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_TASK_MAX]){{ \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_TASK_START] = I2S0_TASK_START_RX, \ [I2S_ETM_TASK_STOP] = I2S0_TASK_STOP_RX, \ diff --git a/components/hal/esp32h2/include/hal/i2s_ll.h b/components/hal/esp32h2/include/hal/i2s_ll.h index 4ebda7da09..8712801a9a 100644 --- a/components/hal/esp32h2/include/hal/i2s_ll.h +++ b/components/hal/esp32h2/include/hal/i2s_ll.h @@ -34,15 +34,13 @@ extern "C" { #define I2S_LL_CLK_FRAC_DIV_N_MAX 256 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the N register is 8 bit-width #define I2S_LL_CLK_FRAC_DIV_AB_MAX 512 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the a/b register is 9 bit-width -/* Add SOC_I2S_TDM_FULL_DATA_WIDTH in the soc_caps to indicate there is no limitation to support full data width (i.e., 16 slots * 32 bits) */ #define I2S_LL_SLOT_FRAME_BIT_MAX 512 // Up-to 512 bits in one frame, determined by MAX(half_sample_bits) * 2 -#define I2S_LL_PLL_F96M_CLK_FREQ (96 * 1000000) // PLL_F96M_CLK: 96MHz -#define I2S_LL_PLL_F64M_CLK_FREQ (64 * 1000000) // PLL_F64M_CLK: 64MHz -#define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_PLL_F96M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT +#define I2S_LL_DEFAULT_CLK_FREQ (96 * 1000000) // PLL_F96M_CLK: 96MHz +#define I2S_LL_SUPPORT_XTAL 1 // Support XTAL as I2S clock source #define I2S_LL_ETM_EVENT_TABLE(i2s_port, chan_dir, event) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_EVENT_MAX]){{ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_EVENT_MAX]){{ \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_EVENT_DONE] = I2S_EVT_RX_DONE, \ [I2S_ETM_EVENT_REACH_THRESH] = I2S_EVT_X_WORDS_RECEIVED, \ @@ -54,7 +52,7 @@ extern "C" { #define I2S_LL_ETM_TASK_TABLE(i2s_port, chan_dir, task) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_TASK_MAX]){{ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_TASK_MAX]){{ \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_TASK_START] = I2S_TASK_START_RX, \ [I2S_ETM_TASK_STOP] = I2S_TASK_STOP_RX, \ diff --git a/components/hal/esp32h4/include/hal/i2s_ll.h b/components/hal/esp32h4/include/hal/i2s_ll.h index d1a97be56a..d35c03189e 100644 --- a/components/hal/esp32h4/include/hal/i2s_ll.h +++ b/components/hal/esp32h4/include/hal/i2s_ll.h @@ -36,15 +36,13 @@ extern "C" { #define I2S_LL_CLK_FRAC_DIV_N_MAX 256 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the N register is 8 bit-width #define I2S_LL_CLK_FRAC_DIV_AB_MAX 512 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the a/b register is 9 bit-width -/* Add SOC_I2S_TDM_FULL_DATA_WIDTH in the soc_caps to indicate there is no limitation to support full data width (i.e., 16 slots * 32 bits) */ #define I2S_LL_SLOT_FRAME_BIT_MAX 512 // Up-to 512 bits in one frame, determined by MAX(half_sample_bits) * 2 -#define I2S_LL_PLL_F96M_CLK_FREQ (96 * 1000000) // PLL_F96M_CLK: 96MHz -#define I2S_LL_PLL_F64M_CLK_FREQ (64 * 1000000) // PLL_F64M_CLK: 64MHz -#define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_PLL_F96M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT +#define I2S_LL_DEFAULT_CLK_FREQ (96 * 1000000) // PLL_F96M_CLK: 96MHz +#define I2S_LL_SUPPORT_XTAL 1 // Support XTAL as I2S clock source #define I2S_LL_ETM_EVENT_TABLE(i2s_port, chan_dir, event) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_EVENT_MAX]){{ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_EVENT_MAX]){{ \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_EVENT_DONE] = I2S0_EVT_RX_DONE, \ [I2S_ETM_EVENT_REACH_THRESH] = I2S0_EVT_X_WORDS_RECEIVED, \ @@ -56,7 +54,7 @@ extern "C" { #define I2S_LL_ETM_TASK_TABLE(i2s_port, chan_dir, task) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_TASK_MAX]){{ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_TASK_MAX]){{ \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_TASK_START] = I2S0_TASK_START_RX, \ [I2S_ETM_TASK_STOP] = I2S0_TASK_STOP_RX, \ diff --git a/components/hal/esp32p4/include/hal/i2s_ll.h b/components/hal/esp32p4/include/hal/i2s_ll.h index e8b21cf4de..a07866946c 100644 --- a/components/hal/esp32p4/include/hal/i2s_ll.h +++ b/components/hal/esp32p4/include/hal/i2s_ll.h @@ -38,7 +38,6 @@ extern "C" { #define I2S_LL_CLK_FRAC_DIV_N_MAX 256 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the N register is 8 bit-width #define I2S_LL_CLK_FRAC_DIV_AB_MAX 512 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the a/b register is 9 bit-width -/* Add SOC_I2S_TDM_FULL_DATA_WIDTH in the soc_caps to indicate there is no limitation to support full data width (i.e., 16 slots * 32 bits) */ #define I2S_LL_SLOT_FRAME_BIT_MAX 512 // Up-to 512 bits in one frame, determined by MAX(half_sample_bits) * 2 #define I2S_LL_XTAL_CLK_FREQ (40 * 1000000) // XTAL_CLK: 40MHz @@ -49,10 +48,10 @@ extern "C" { #define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_XTAL_CLK_FREQ // No PLL clock source before version 3, use XTAL as default #define I2S_LL_DEFAULT_CLK_SRC I2S_CLK_SRC_XTAL #endif - +#define I2S_LL_SUPPORT_XTAL 1 // Support XTAL as I2S clock source #define I2S_LL_ETM_EVENT_TABLE(i2s_port, chan_dir, event) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_EVENT_MAX]){ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_EVENT_MAX]){ \ [0] = { \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_EVENT_DONE] = I2S0_EVT_RX_DONE, \ @@ -87,7 +86,7 @@ extern "C" { #define I2S_LL_ETM_TASK_TABLE(i2s_port, chan_dir, task) \ - (uint32_t[SOC_I2S_NUM][2][I2S_ETM_TASK_MAX]){ \ + (uint32_t[SOC_I2S_ATTR(INST_NUM)][2][I2S_ETM_TASK_MAX]){ \ [0] = { \ [I2S_DIR_RX - 1] = { \ [I2S_ETM_TASK_START] = I2S0_TASK_START_RX, \ diff --git a/components/hal/esp32s2/include/hal/i2s_ll.h b/components/hal/esp32s2/include/hal/i2s_ll.h index 525b71ecc2..d3557c5baa 100644 --- a/components/hal/esp32s2/include/hal/i2s_ll.h +++ b/components/hal/esp32s2/include/hal/i2s_ll.h @@ -47,8 +47,7 @@ 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 -#define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT +#define I2S_LL_DEFAULT_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz /** * @brief Enable DMA descriptor owner check diff --git a/components/hal/esp32s3/include/hal/i2s_ll.h b/components/hal/esp32s3/include/hal/i2s_ll.h index c9e4f02bc2..9a9801e0fe 100644 --- a/components/hal/esp32s3/include/hal/i2s_ll.h +++ b/components/hal/esp32s3/include/hal/i2s_ll.h @@ -36,8 +36,8 @@ extern "C" { #define I2S_LL_CLK_FRAC_DIV_AB_MAX 512 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the a/b register is 9 bit-width #define I2S_LL_SLOT_FRAME_BIT_MAX 128 // Up-to 128 bits in one frame, determined by MAX(half_sample_bits) * 2 -#define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz -#define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT +#define I2S_LL_DEFAULT_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz +#define I2S_LL_SUPPORT_XTAL 1 // Support XTAL as I2S clock source /** diff --git a/components/hal/include/hal/i2s_hal.h b/components/hal/include/hal/i2s_hal.h index 88ab092330..f67fb6fd21 100644 --- a/components/hal/include/hal/i2s_hal.h +++ b/components/hal/include/hal/i2s_hal.h @@ -16,7 +16,7 @@ #pragma once #include "soc/soc_caps.h" -#if SOC_I2S_SUPPORTED +#if SOC_HAS(I2S) #include "hal/i2s_types.h" #include "hal/i2s_ll.h" #endif @@ -25,7 +25,7 @@ extern "C" { #endif -#if SOC_I2S_SUPPORTED +#if SOC_HAS(I2S) /** * @brief General slot configuration information * @note It is a general purpose struct, not supposed to be used directly by user @@ -138,7 +138,7 @@ typedef struct { * @brief Init I2S hal context * * @param hal Context of the HAL layer - * @param port_id The I2S port number, the max port number is (SOC_I2S_NUM -1) + * @param port_id The I2S port number, the max port number is (SOC_I2S_ATTR(INST_NUM) -1) */ void i2s_hal_init(i2s_hal_context_t *hal, int port_id); diff --git a/components/hal/include/hal/i2s_types.h b/components/hal/include/hal/i2s_types.h index 8709b3f062..feb2683660 100644 --- a/components/hal/include/hal/i2s_types.h +++ b/components/hal/include/hal/i2s_types.h @@ -64,7 +64,7 @@ typedef enum { I2S_SLOT_BIT_WIDTH_32BIT = (32), /*!< I2S channel slot bit-width: 32 */ } i2s_slot_bit_width_t; -#if SOC_I2S_SUPPORTED +#if SOC_HAS(I2S) typedef soc_periph_i2s_clk_src_t i2s_clock_src_t; /*!< I2S clock source */ #else typedef int i2s_clock_src_t; /*!< Define a default type to avoid compiling warnings */ diff --git a/components/soc/esp32/i2s_periph.c b/components/soc/esp32/i2s_periph.c index 9f06c85f40..2a37538bf5 100644 --- a/components/soc/esp32/i2s_periph.c +++ b/components/soc/esp32/i2s_periph.c @@ -10,7 +10,7 @@ /* Bunch of constants for every I2S peripheral: GPIO signals, irqs, hw addr of registers etc */ -const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM] = { +const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_ATTR(INST_NUM)] = { { .mck_out_sig = -1, // Unavailable .mck_in_sig = -1, // Unavailable diff --git a/components/soc/esp32/include/soc/Kconfig.soc_caps.in b/components/soc/esp32/include/soc/Kconfig.soc_caps.in index 36bda8aacc..7b04eba242 100644 --- a/components/soc/esp32/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32/include/soc/Kconfig.soc_caps.in @@ -383,10 +383,6 @@ config SOC_I2C_STOP_INDEPENDENT bool default y -config SOC_I2S_NUM - int - default 2 - config SOC_I2S_HW_VERSION_1 bool default y @@ -395,10 +391,6 @@ 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 @@ -427,30 +419,10 @@ config SOC_I2S_PDM_MAX_RX_LINES int default 1 -config SOC_I2S_SUPPORTS_ADC_DAC - bool - default y - -config SOC_I2S_SUPPORTS_ADC - bool - default y - config SOC_I2S_SUPPORTS_LCD_CAMERA bool default y -config SOC_I2S_MAX_DATA_WIDTH - int - default 24 - -config SOC_I2S_TRANS_SIZE_ALIGN_WORD - bool - default y - -config SOC_I2S_LCD_I80_VARIANT - bool - default y - config SOC_LCD_I80_SUPPORTED bool default y diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index 8a22bebce8..71a3a1a576 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -217,10 +217,8 @@ /*-------------------------- I2S CAPS ----------------------------------------*/ // ESP32 has 2 I2S -#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) // Support to output raw PDM format data #define SOC_I2S_SUPPORTS_PCM2PDM (1) // Support to write PCM format but output PDM format data with the help of PCM to PDM filter @@ -228,13 +226,7 @@ #define SOC_I2S_SUPPORTS_PDM2PCM (1) // Support to input PDM format but read PCM format data with the help of PDM to PCM filter #define SOC_I2S_PDM_MAX_TX_LINES (1U) #define SOC_I2S_PDM_MAX_RX_LINES (1U) -#define SOC_I2S_SUPPORTS_ADC_DAC (1) -#define SOC_I2S_SUPPORTS_ADC (1) #define SOC_I2S_SUPPORTS_LCD_CAMERA (1) -#define SOC_I2S_MAX_DATA_WIDTH (24) - -#define SOC_I2S_TRANS_SIZE_ALIGN_WORD (1) // I2S DMA transfer size must be aligned to word -#define SOC_I2S_LCD_I80_VARIANT (1) // I2S has a special LCD mode that can generate Intel 8080 TX timing /*-------------------------- LCD CAPS ----------------------------------------*/ /* Notes: On esp32, LCD intel 8080 timing is generated by I2S peripheral */ diff --git a/components/soc/esp32/include/soc/soc_caps_full.h b/components/soc/esp32/include/soc/soc_caps_full.h index 5ae5119a7f..1ba59c1f54 100644 --- a/components/soc/esp32/include/soc/soc_caps_full.h +++ b/components/soc/esp32/include/soc/soc_caps_full.h @@ -29,3 +29,10 @@ #define _SOC_CAPS_PCNT_UNITS_PER_INST 8 // Number of units in each PCNT instance #define _SOC_CAPS_PCNT_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit #define _SOC_CAPS_PCNT_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit + +/*------------------------------- I2S ---------------------------------------*/ +// helper macros to access module attributes +#define _SOC_CAPS_I2S_INST_NUM 2 // Number of I2S instances +#define _SOC_CAPS_I2S_MAX_DATA_WIDTH 24 // Maximum data line width of I2S +#define _SOC_CAPS_I2S_TRANS_SIZE_ALIGN_WORD 1 // I2S DMA transfer size must be aligned to word +#define _SOC_CAPS_I2S_SUPPORT_ADC_DAC 1 // I2S supports to connect to ADC / DAC converters diff --git a/components/soc/esp32c3/i2s_periph.c b/components/soc/esp32c3/i2s_periph.c index dfb1ba6df8..77c2d7e7dd 100644 --- a/components/soc/esp32c3/i2s_periph.c +++ b/components/soc/esp32c3/i2s_periph.c @@ -10,7 +10,7 @@ /* Bunch of constants for every I2S peripheral: GPIO signals, irqs, hw addr of registers etc */ -const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM] = { +const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_ATTR(INST_NUM)] = { { .mck_out_sig = I2S_MCLK_OUT_IDX, .mck_in_sig = I2S_MCLK_IN_IDX, diff --git a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in index 40730abf27..892c1e48a9 100644 --- a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in @@ -479,22 +479,10 @@ config SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS bool default y -config SOC_I2S_NUM - int - default 1 - config SOC_I2S_HW_VERSION_2 bool default y -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 95e1421682..ae29f5483e 100644 --- a/components/soc/esp32c3/include/soc/soc_caps.h +++ b/components/soc/esp32c3/include/soc/soc_caps.h @@ -213,10 +213,7 @@ #define SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS (1) /*-------------------------- I2S CAPS ----------------------------------------*/ -#define SOC_I2S_NUM (1U) #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) // Support to output raw PDM format data diff --git a/components/soc/esp32c3/include/soc/soc_caps_full.h b/components/soc/esp32c3/include/soc/soc_caps_full.h index a86519dfb5..b372e0a2d8 100644 --- a/components/soc/esp32c3/include/soc/soc_caps_full.h +++ b/components/soc/esp32c3/include/soc/soc_caps_full.h @@ -27,3 +27,7 @@ /*------------------------------- Dedicated GPIO ------------------------------*/ #define _SOC_CAPS_DEDIC_GPIO_OUT_CHANS_PER_CPU 8 /*!< 8 outward channels on each CPU core */ #define _SOC_CAPS_DEDIC_GPIO_IN_CHANS_PER_CPU 8 /*!< 8 inward channels on each CPU core */ + +/*------------------------------- I2S ---------------------------------------*/ +// helper macros to access module attributes +#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances diff --git a/components/soc/esp32c5/i2s_periph.c b/components/soc/esp32c5/i2s_periph.c index 9866cc9789..d68576b304 100644 --- a/components/soc/esp32c5/i2s_periph.c +++ b/components/soc/esp32c5/i2s_periph.c @@ -11,7 +11,7 @@ /* Bunch of constants for every I2S peripheral: GPIO signals, irqs, hw addr of registers etc */ -const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM] = { +const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_ATTR(INST_NUM)] = { { .mck_out_sig = I2S_MCLK_OUT_IDX, .mck_in_sig = I2S_MCLK_IN_IDX, @@ -64,7 +64,7 @@ static const uint32_t i2s_regs_map[4] = {0x12360f, 0x0, 0x0, 0x0}; static const regdma_entries_config_t i2s0_regs_retention[] = I2S_SLEEP_RETENTION_ENTRIES(0); -const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_NUM] = { +const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_ATTR(INST_NUM)] = { [0] = { .retention_module = SLEEP_RETENTION_MODULE_I2S0, .entry_array = i2s0_regs_retention, diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index f5d8a5c822..67a3347ee7 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -707,10 +707,6 @@ config SOC_LP_I2C_FIFO_LEN int default 16 -config SOC_I2S_NUM - int - default 1 - config SOC_I2S_HW_VERSION_2 bool default y @@ -719,18 +715,6 @@ config SOC_I2S_SUPPORTS_ETM bool default y -config SOC_I2S_SUPPORTS_XTAL - bool - default y - -config SOC_I2S_SUPPORTS_PLL_F160M - bool - default y - -config SOC_I2S_SUPPORTS_PLL_F240M - bool - default y - config SOC_I2S_SUPPORTS_PCM bool default y @@ -767,14 +751,6 @@ config SOC_I2S_SUPPORTS_TDM bool default y -config SOC_I2S_TDM_FULL_DATA_WIDTH - bool - default y - -config SOC_I2S_SUPPORT_SLEEP_RETENTION - bool - default y - config SOC_LEDC_SUPPORT_PLL_DIV_CLOCK bool default y diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index 7f301dbbd5..748fbcfd8c 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -294,12 +294,8 @@ #define SOC_LP_I2C_FIFO_LEN (16) /*!< LP_I2C hardware FIFO depth */ /*-------------------------- I2S CAPS ----------------------------------------*/ -#define SOC_I2S_NUM (1U) #define SOC_I2S_HW_VERSION_2 (1) #define SOC_I2S_SUPPORTS_ETM (1) -#define SOC_I2S_SUPPORTS_XTAL (1) -#define SOC_I2S_SUPPORTS_PLL_F160M (1) -#define SOC_I2S_SUPPORTS_PLL_F240M (1) #define SOC_I2S_SUPPORTS_PCM (1) #define SOC_I2S_SUPPORTS_PDM (1) #define SOC_I2S_SUPPORTS_PDM_TX (1) // Support to output raw PDM format data @@ -309,8 +305,6 @@ #define SOC_I2S_PDM_MAX_TX_LINES (2) #define SOC_I2S_PDM_MAX_RX_LINES (1U) #define SOC_I2S_SUPPORTS_TDM (1) -#define SOC_I2S_TDM_FULL_DATA_WIDTH (1) /*!< No limitation to data bit width when using multiple slots */ -#define SOC_I2S_SUPPORT_SLEEP_RETENTION 1 /*!< The sleep retention feature can help back up I2S registers before sleep */ /*-------------------------- LEDC CAPS ---------------------------------------*/ #define SOC_LEDC_SUPPORT_PLL_DIV_CLOCK (1) diff --git a/components/soc/esp32c5/include/soc/soc_caps_full.h b/components/soc/esp32c5/include/soc/soc_caps_full.h index b28c26cdbf..ed140ded39 100644 --- a/components/soc/esp32c5/include/soc/soc_caps_full.h +++ b/components/soc/esp32c5/include/soc/soc_caps_full.h @@ -37,3 +37,7 @@ /*--------------------------- ETM (Event Task Matrix) ----------------------------*/ #define _SOC_CAPS_ETM_INST_NUM 1 // Number of ETM instances #define _SOC_CAPS_ETM_CHANS_PER_INST 50 // Number of channels in each ETM instance + +/*------------------------------- I2S ---------------------------------------*/ +// helper macros to access module attributes +#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances diff --git a/components/soc/esp32c6/i2s_periph.c b/components/soc/esp32c6/i2s_periph.c index fb1cea5bb1..8b28b8952f 100644 --- a/components/soc/esp32c6/i2s_periph.c +++ b/components/soc/esp32c6/i2s_periph.c @@ -11,7 +11,7 @@ /* Bunch of constants for every I2S peripheral: GPIO signals, irqs, hw addr of registers etc */ -const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM] = { +const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_ATTR(INST_NUM)] = { { .mck_out_sig = I2S_MCLK_OUT_IDX, .mck_in_sig = I2S_MCLK_IN_IDX, @@ -64,7 +64,7 @@ static const uint32_t i2s_regs_map[4] = {0x12330f, 0x0, 0x0, 0x0}; static const regdma_entries_config_t i2s0_regs_retention[] = I2S_SLEEP_RETENTION_ENTRIES(0); -const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_NUM] = { +const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_ATTR(INST_NUM)] = { [0] = { .retention_module = SLEEP_RETENTION_MODULE_I2S0, .entry_array = i2s0_regs_retention, diff --git a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in index 8e4e985521..cae0c0bd21 100644 --- a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in @@ -635,10 +635,6 @@ config SOC_LP_I2C_FIFO_LEN int default 16 -config SOC_I2S_NUM - int - default 1 - config SOC_I2S_HW_VERSION_2 bool default y @@ -647,14 +643,6 @@ config SOC_I2S_SUPPORTS_ETM bool default y -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 @@ -687,10 +675,6 @@ config SOC_I2S_SUPPORTS_TDM bool default y -config SOC_I2S_SUPPORT_SLEEP_RETENTION - bool - default y - config SOC_LEDC_SUPPORT_PLL_DIV_CLOCK bool default y diff --git a/components/soc/esp32c6/include/soc/soc_caps.h b/components/soc/esp32c6/include/soc/soc_caps.h index 2f68ede25a..33971bb987 100644 --- a/components/soc/esp32c6/include/soc/soc_caps.h +++ b/components/soc/esp32c6/include/soc/soc_caps.h @@ -271,11 +271,8 @@ #define SOC_LP_I2C_FIFO_LEN (16) /*!< LP_I2C hardware FIFO depth */ /*-------------------------- I2S CAPS ----------------------------------------*/ -#define SOC_I2S_NUM (1U) #define SOC_I2S_HW_VERSION_2 (1) #define SOC_I2S_SUPPORTS_ETM (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) // Support to output raw PDM format data @@ -284,7 +281,6 @@ #define SOC_I2S_PDM_MAX_TX_LINES (2) #define SOC_I2S_PDM_MAX_RX_LINES (1U) #define SOC_I2S_SUPPORTS_TDM (1) -#define SOC_I2S_SUPPORT_SLEEP_RETENTION 1 /*!< The sleep retention feature can help back up I2S registers before sleep */ /*-------------------------- LEDC CAPS ---------------------------------------*/ #define SOC_LEDC_SUPPORT_PLL_DIV_CLOCK (1) diff --git a/components/soc/esp32c6/include/soc/soc_caps_full.h b/components/soc/esp32c6/include/soc/soc_caps_full.h index b28c26cdbf..ed140ded39 100644 --- a/components/soc/esp32c6/include/soc/soc_caps_full.h +++ b/components/soc/esp32c6/include/soc/soc_caps_full.h @@ -37,3 +37,7 @@ /*--------------------------- ETM (Event Task Matrix) ----------------------------*/ #define _SOC_CAPS_ETM_INST_NUM 1 // Number of ETM instances #define _SOC_CAPS_ETM_CHANS_PER_INST 50 // Number of channels in each ETM instance + +/*------------------------------- I2S ---------------------------------------*/ +// helper macros to access module attributes +#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances diff --git a/components/soc/esp32c61/i2s_periph.c b/components/soc/esp32c61/i2s_periph.c index 667c4d3e9f..80101da6f9 100644 --- a/components/soc/esp32c61/i2s_periph.c +++ b/components/soc/esp32c61/i2s_periph.c @@ -11,7 +11,7 @@ /* Bunch of constants for every I2S peripheral: GPIO signals, irqs, hw addr of registers etc */ -const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM] = { +const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_ATTR(INST_NUM)] = { { .mck_out_sig = I2S_MCLK_OUT_IDX, .mck_in_sig = I2S_MCLK_IN_IDX, @@ -64,7 +64,7 @@ static const uint32_t i2s_regs_map[4] = {0x12360f, 0x0, 0x0, 0x0}; static const regdma_entries_config_t i2s0_regs_retention[] = I2S_SLEEP_RETENTION_ENTRIES(0); -const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_NUM] = { +const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_ATTR(INST_NUM)] = { [0] = { .retention_module = SLEEP_RETENTION_MODULE_I2S0, .entry_array = i2s0_regs_retention, diff --git a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in index 07b79e6fee..b181c25057 100644 --- a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in @@ -571,10 +571,6 @@ config SOC_I2C_SUPPORT_SLEEP_RETENTION bool default y -config SOC_I2S_NUM - int - default 1 - config SOC_I2S_HW_VERSION_2 bool default y @@ -583,18 +579,6 @@ config SOC_I2S_SUPPORTS_ETM bool default y -config SOC_I2S_SUPPORTS_XTAL - bool - default y - -config SOC_I2S_SUPPORTS_PLL_F160M - bool - default y - -config SOC_I2S_SUPPORTS_PLL_F120M - bool - default y - config SOC_I2S_SUPPORTS_PCM bool default y @@ -631,14 +615,6 @@ config SOC_I2S_SUPPORTS_TDM bool default y -config SOC_I2S_TDM_FULL_DATA_WIDTH - bool - default y - -config SOC_I2S_SUPPORT_SLEEP_RETENTION - bool - default y - config SOC_LEDC_SUPPORT_PLL_DIV_CLOCK bool default y diff --git a/components/soc/esp32c61/include/soc/soc_caps.h b/components/soc/esp32c61/include/soc/soc_caps.h index 35607db54d..a1865467cc 100644 --- a/components/soc/esp32c61/include/soc/soc_caps.h +++ b/components/soc/esp32c61/include/soc/soc_caps.h @@ -242,12 +242,8 @@ #define SOC_I2C_SUPPORT_SLEEP_RETENTION (1) // /*-------------------------- I2S CAPS ----------------------------------------*/ -#define SOC_I2S_NUM (1U) #define SOC_I2S_HW_VERSION_2 (1) #define SOC_I2S_SUPPORTS_ETM (1) -#define SOC_I2S_SUPPORTS_XTAL (1) -#define SOC_I2S_SUPPORTS_PLL_F160M (1) -#define SOC_I2S_SUPPORTS_PLL_F120M (1) #define SOC_I2S_SUPPORTS_PCM (1) #define SOC_I2S_SUPPORTS_PDM (1) #define SOC_I2S_SUPPORTS_PDM_TX (1) // Support to output raw PDM format data @@ -257,8 +253,6 @@ #define SOC_I2S_PDM_MAX_TX_LINES (2) #define SOC_I2S_PDM_MAX_RX_LINES (1U) #define SOC_I2S_SUPPORTS_TDM (1) -#define SOC_I2S_TDM_FULL_DATA_WIDTH (1) /*!< No limitation to data bit width when using multiple slots */ -#define SOC_I2S_SUPPORT_SLEEP_RETENTION (1) /*-------------------------- LEDC CAPS ---------------------------------------*/ #define SOC_LEDC_SUPPORT_PLL_DIV_CLOCK (1) diff --git a/components/soc/esp32c61/include/soc/soc_caps_full.h b/components/soc/esp32c61/include/soc/soc_caps_full.h index 59637b63cc..c687e7c92b 100644 --- a/components/soc/esp32c61/include/soc/soc_caps_full.h +++ b/components/soc/esp32c61/include/soc/soc_caps_full.h @@ -27,3 +27,7 @@ /*--------------------------- ETM (Event Task Matrix) ----------------------------*/ #define _SOC_CAPS_ETM_INST_NUM 1 // Number of ETM instances #define _SOC_CAPS_ETM_CHANS_PER_INST 50 // Number of channels in each ETM instance + +/*--------------------------- I2S CAPS ----------------------------------------*/ +// helper macros to access module attributes +#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances diff --git a/components/soc/esp32h2/i2s_periph.c b/components/soc/esp32h2/i2s_periph.c index 818b4e1080..594170f8af 100644 --- a/components/soc/esp32h2/i2s_periph.c +++ b/components/soc/esp32h2/i2s_periph.c @@ -11,7 +11,7 @@ /* Bunch of constants for every I2S peripheral: GPIO signals, irqs, hw addr of registers etc */ -const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM] = { +const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_ATTR(INST_NUM)] = { { .mck_out_sig = I2S_MCLK_OUT_IDX, .mck_in_sig = I2S_MCLK_IN_IDX, @@ -63,7 +63,7 @@ static const uint32_t i2s_regs_map[4] = {0x12330f, 0x0, 0x0, 0x0}; static const regdma_entries_config_t i2s0_regs_retention[] = I2S_SLEEP_RETENTION_ENTRIES(0); -const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_NUM] = { +const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_ATTR(INST_NUM)] = { [0] = { .retention_module = SLEEP_RETENTION_MODULE_I2S0, .entry_array = i2s0_regs_retention, diff --git a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in index 3809d59521..8cfa4bbbd8 100644 --- a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in @@ -639,10 +639,6 @@ config SOC_I2C_SUPPORT_SLEEP_RETENTION bool default y -config SOC_I2S_NUM - int - default 1 - config SOC_I2S_HW_VERSION_2 bool default y @@ -651,18 +647,6 @@ config SOC_I2S_SUPPORTS_ETM bool default y -config SOC_I2S_SUPPORTS_XTAL - bool - default y - -config SOC_I2S_SUPPORTS_PLL_F96M - bool - default y - -config SOC_I2S_SUPPORTS_PLL_F64M - bool - default y - config SOC_I2S_SUPPORTS_PCM bool default y @@ -695,14 +679,6 @@ config SOC_I2S_SUPPORTS_TDM bool default y -config SOC_I2S_TDM_FULL_DATA_WIDTH - bool - default y - -config SOC_I2S_SUPPORT_SLEEP_RETENTION - bool - default y - config SOC_LEDC_SUPPORT_PLL_DIV_CLOCK bool default y diff --git a/components/soc/esp32h2/include/soc/soc_caps.h b/components/soc/esp32h2/include/soc/soc_caps.h index d7b6721057..bda8de69b2 100644 --- a/components/soc/esp32h2/include/soc/soc_caps.h +++ b/components/soc/esp32h2/include/soc/soc_caps.h @@ -289,12 +289,8 @@ #define SOC_I2C_SUPPORT_SLEEP_RETENTION (1) /*-------------------------- I2S CAPS ----------------------------------------*/ -#define SOC_I2S_NUM (1U) #define SOC_I2S_HW_VERSION_2 (1) #define SOC_I2S_SUPPORTS_ETM (1) -#define SOC_I2S_SUPPORTS_XTAL (1) -#define SOC_I2S_SUPPORTS_PLL_F96M (1) -#define SOC_I2S_SUPPORTS_PLL_F64M (1) #define SOC_I2S_SUPPORTS_PCM (1) #define SOC_I2S_SUPPORTS_PDM (1) #define SOC_I2S_SUPPORTS_PDM_TX (1) // Support to output raw PDM format data @@ -303,8 +299,6 @@ #define SOC_I2S_PDM_MAX_TX_LINES (2) #define SOC_I2S_PDM_MAX_RX_LINES (1U) #define SOC_I2S_SUPPORTS_TDM (1) -#define SOC_I2S_TDM_FULL_DATA_WIDTH (1) /*!< No limitation to data bit width when using multiple slots */ -#define SOC_I2S_SUPPORT_SLEEP_RETENTION 1 /*!< The sleep retention feature can help back up I2S registers before sleep */ /*-------------------------- LEDC CAPS ---------------------------------------*/ #define SOC_LEDC_SUPPORT_PLL_DIV_CLOCK (1) diff --git a/components/soc/esp32h2/include/soc/soc_caps_full.h b/components/soc/esp32h2/include/soc/soc_caps_full.h index b28c26cdbf..ed140ded39 100644 --- a/components/soc/esp32h2/include/soc/soc_caps_full.h +++ b/components/soc/esp32h2/include/soc/soc_caps_full.h @@ -37,3 +37,7 @@ /*--------------------------- ETM (Event Task Matrix) ----------------------------*/ #define _SOC_CAPS_ETM_INST_NUM 1 // Number of ETM instances #define _SOC_CAPS_ETM_CHANS_PER_INST 50 // Number of channels in each ETM instance + +/*------------------------------- I2S ---------------------------------------*/ +// helper macros to access module attributes +#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances diff --git a/components/soc/esp32h21/include/soc/soc_caps.h b/components/soc/esp32h21/include/soc/soc_caps.h index 985f477efa..51e3a50d2a 100644 --- a/components/soc/esp32h21/include/soc/soc_caps.h +++ b/components/soc/esp32h21/include/soc/soc_caps.h @@ -270,18 +270,13 @@ // #define SOC_I2C_SUPPORT_SLEEP_RETENTION (1) /*-------------------------- I2S CAPS ----------------------------------------*/ -// #define SOC_I2S_NUM (1U) // #define SOC_I2S_HW_VERSION_2 (1) // // #define SOC_I2S_SUPPORTS_ETM (1) -// #define SOC_I2S_SUPPORTS_XTAL (1) -// #define SOC_I2S_SUPPORTS_PLL_F96M (1) -// #define SOC_I2S_SUPPORTS_PLL_F64M (1) // #define SOC_I2S_SUPPORTS_PCM (1) // #define SOC_I2S_SUPPORTS_PDM (1) // #define SOC_I2S_SUPPORTS_PDM_TX (1) // #define SOC_I2S_PDM_MAX_TX_LINES (2) // #define SOC_I2S_SUPPORTS_TDM (1) -// #define SOC_I2S_TDM_FULL_DATA_WIDTH (1) /*!< No limitation to data bit width when using multiple slots */ /*-------------------------- LEDC CAPS ---------------------------------------*/ #define SOC_LEDC_SUPPORT_PLL_DIV_CLOCK (1) diff --git a/components/soc/esp32h21/include/soc/soc_caps_full.h b/components/soc/esp32h21/include/soc/soc_caps_full.h index 95748b6bc6..6d4fd50636 100644 --- a/components/soc/esp32h21/include/soc/soc_caps_full.h +++ b/components/soc/esp32h21/include/soc/soc_caps_full.h @@ -33,3 +33,7 @@ /*--------------------------- ETM (Event Task Matrix) ----------------------------*/ #define _SOC_CAPS_ETM_INST_NUM 1 // Number of ETM instances #define _SOC_CAPS_ETM_CHANS_PER_INST 50 // Number of channels in each ETM instance + +/*------------------------------- I2S ---------------------------------------*/ +// helper macros to access module attributes +// #define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances diff --git a/components/soc/esp32h4/i2s_periph.c b/components/soc/esp32h4/i2s_periph.c index 2e3b4d82b4..64b5ec593f 100644 --- a/components/soc/esp32h4/i2s_periph.c +++ b/components/soc/esp32h4/i2s_periph.c @@ -11,7 +11,7 @@ /* Bunch of constants for every I2S peripheral: GPIO signals, irqs, hw addr of registers etc */ -const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM] = { +const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_ATTR(INST_NUM)] = { { .mck_out_sig = I2S_MCLK_OUT_IDX, .mck_in_sig = I2S_MCLK_IN_IDX, @@ -68,7 +68,7 @@ static const uint32_t i2s_regs_map[4] = {0xf191b079, 0x0, 0x0, 0x0}; }; static const regdma_entries_config_t i2s0_regs_retention[] = I2S_SLEEP_RETENTION_ENTRIES(0); -const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_NUM] = { +const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_ATTR(INST_NUM)] = { [0] = { .retention_module = SLEEP_RETENTION_MODULE_I2S0, .entry_array = i2s0_regs_retention, diff --git a/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in index 0f9f9348d0..f47b135f97 100644 --- a/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in @@ -419,10 +419,6 @@ config SOC_I2C_SUPPORT_SLEEP_RETENTION bool default y -config SOC_I2S_NUM - int - default 1 - config SOC_I2S_HW_VERSION_2 bool default y @@ -431,18 +427,6 @@ config SOC_I2S_SUPPORTS_ETM bool default y -config SOC_I2S_SUPPORTS_XTAL - bool - default y - -config SOC_I2S_SUPPORTS_PLL_F96M - bool - default y - -config SOC_I2S_SUPPORTS_PLL_F64M - bool - default y - config SOC_I2S_SUPPORTS_PCM bool default y @@ -483,14 +467,6 @@ config SOC_I2S_SUPPORTS_TDM bool default y -config SOC_I2S_TDM_FULL_DATA_WIDTH - bool - default y - -config SOC_I2S_SUPPORT_SLEEP_RETENTION - bool - default y - config SOC_LEDC_SUPPORT_PLL_DIV_CLOCK bool default y diff --git a/components/soc/esp32h4/include/soc/soc_caps.h b/components/soc/esp32h4/include/soc/soc_caps.h index 741fda7758..919b28176a 100644 --- a/components/soc/esp32h4/include/soc/soc_caps.h +++ b/components/soc/esp32h4/include/soc/soc_caps.h @@ -268,12 +268,8 @@ #define SOC_I2C_SUPPORT_SLEEP_RETENTION (1) /*-------------------------- I2S CAPS ----------------------------------------*/ -#define SOC_I2S_NUM (1U) #define SOC_I2S_HW_VERSION_2 (1) #define SOC_I2S_SUPPORTS_ETM (1) -#define SOC_I2S_SUPPORTS_XTAL (1) -#define SOC_I2S_SUPPORTS_PLL_F96M (1) -#define SOC_I2S_SUPPORTS_PLL_F64M (1) #define SOC_I2S_SUPPORTS_PCM (1) #define SOC_I2S_SUPPORTS_PDM (1) #define SOC_I2S_SUPPORTS_PDM_TX (1) // Support to output raw PDM format data @@ -284,9 +280,6 @@ #define SOC_I2S_PDM_MAX_TX_LINES (2) #define SOC_I2S_PDM_MAX_RX_LINES (1U) #define SOC_I2S_SUPPORTS_TDM (1) -#define SOC_I2S_TDM_FULL_DATA_WIDTH (1) /*!< No limitation to data bit width when using multiple slots */ - -#define SOC_I2S_SUPPORT_SLEEP_RETENTION 1 /*!< The sleep retention feature can help back up I2S registers before sleep */ /*-------------------------- LEDC CAPS ---------------------------------------*/ #define SOC_LEDC_SUPPORT_PLL_DIV_CLOCK (1) diff --git a/components/soc/esp32h4/include/soc/soc_caps_full.h b/components/soc/esp32h4/include/soc/soc_caps_full.h index 95748b6bc6..79ab3fc4a2 100644 --- a/components/soc/esp32h4/include/soc/soc_caps_full.h +++ b/components/soc/esp32h4/include/soc/soc_caps_full.h @@ -33,3 +33,7 @@ /*--------------------------- ETM (Event Task Matrix) ----------------------------*/ #define _SOC_CAPS_ETM_INST_NUM 1 // Number of ETM instances #define _SOC_CAPS_ETM_CHANS_PER_INST 50 // Number of channels in each ETM instance + +/*------------------------------- I2S ---------------------------------------*/ +// helper macros to access module attributes +#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances diff --git a/components/soc/esp32p4/i2s_periph.c b/components/soc/esp32p4/i2s_periph.c index 4391c6e05e..e750d2e27d 100644 --- a/components/soc/esp32p4/i2s_periph.c +++ b/components/soc/esp32p4/i2s_periph.c @@ -12,7 +12,7 @@ /* Bunch of constants for every I2S peripheral: GPIO signals, irqs, hw addr of registers etc */ -const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM] = { +const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_ATTR(INST_NUM)] = { [0] = { .mck_out_sig = I2S0_MCLK_PAD_OUT_IDX, .mck_in_sig = I2S0_MCLK_PAD_IN_IDX, @@ -143,7 +143,7 @@ static const regdma_entries_config_t i2s0_regs_retention[] = I2S_SLEEP_RETENTION static const regdma_entries_config_t i2s1_regs_retention[] = I2S_SLEEP_RETENTION_ENTRIES(1); static const regdma_entries_config_t i2s2_regs_retention[] = I2S_SLEEP_RETENTION_ENTRIES(2); -const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_NUM] = { +const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_ATTR(INST_NUM)] = { [0] = { .retention_module = SLEEP_RETENTION_MODULE_I2S0, .entry_array = i2s0_regs_retention, diff --git a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in index 212952840e..eef244f169 100644 --- a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in @@ -839,10 +839,6 @@ config SOC_LP_I2C_FIFO_LEN int default 16 -config SOC_I2S_NUM - int - default 3 - config SOC_I2S_HW_VERSION_2 bool default y @@ -851,10 +847,6 @@ config SOC_I2S_SUPPORTS_ETM bool default y -config SOC_I2S_SUPPORTS_XTAL - bool - default y - config SOC_I2S_SUPPORTS_APLL bool default y @@ -903,14 +895,6 @@ config SOC_I2S_PDM_MAX_RX_LINES int default 4 -config SOC_I2S_TDM_FULL_DATA_WIDTH - bool - default y - -config SOC_I2S_SUPPORT_SLEEP_RETENTION - bool - default y - config SOC_LP_I2S_NUM int default 1 diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index a35e9ff269..e1a5aecf04 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -330,10 +330,8 @@ #define SOC_LP_I2C_FIFO_LEN (16) /*!< LP_I2C hardware FIFO depth */ /*-------------------------- I2S CAPS ----------------------------------------*/ -#define SOC_I2S_NUM (3U) #define SOC_I2S_HW_VERSION_2 (1) #define SOC_I2S_SUPPORTS_ETM (1) -#define SOC_I2S_SUPPORTS_XTAL (1) #define SOC_I2S_SUPPORTS_APLL (1) #define SOC_I2S_SUPPORTS_PCM (1) #define SOC_I2S_SUPPORTS_PDM (1) @@ -346,8 +344,6 @@ #define SOC_I2S_SUPPORTS_TDM (1) #define SOC_I2S_PDM_MAX_TX_LINES (2) // On I2S0 #define SOC_I2S_PDM_MAX_RX_LINES (4) // On I2S0 -#define SOC_I2S_TDM_FULL_DATA_WIDTH (1) /*!< No limitation to data bit width when using multiple slots */ -#define SOC_I2S_SUPPORT_SLEEP_RETENTION 1 /*!< The sleep retention feature can help back up I2S registers before sleep */ /*-------------------------- LP_I2S CAPS -------------------------------------*/ #define SOC_LP_I2S_NUM (1U) diff --git a/components/soc/esp32p4/include/soc/soc_caps_full.h b/components/soc/esp32p4/include/soc/soc_caps_full.h index 2d08cd4501..4d0e945d72 100644 --- a/components/soc/esp32p4/include/soc/soc_caps_full.h +++ b/components/soc/esp32p4/include/soc/soc_caps_full.h @@ -40,3 +40,7 @@ /*--------------------------- MIPI DSI -------------------------------------------*/ #define _SOC_CAPS_MIPI_DSI_INST_NUM 1 // Number of MIPI DSI instances + +/*------------------------------- I2S ---------------------------------------*/ +// helper macros to access module attributes +#define _SOC_CAPS_I2S_INST_NUM 3 // Number of I2S instances diff --git a/components/soc/esp32s2/i2s_periph.c b/components/soc/esp32s2/i2s_periph.c index c13b47926d..a5a12e552c 100644 --- a/components/soc/esp32s2/i2s_periph.c +++ b/components/soc/esp32s2/i2s_periph.c @@ -10,7 +10,7 @@ /* Bunch of constants for every I2S peripheral: GPIO signals, irqs, hw addr of registers etc */ -const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM] = { +const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_ATTR(INST_NUM)] = { { .mck_out_sig = CLK_I2S_MUX_IDX, .mck_in_sig = -1, // Unavailable diff --git a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in index 65ea10de0c..efe025e337 100644 --- a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in @@ -451,10 +451,6 @@ config SOC_I2C_SUPPORT_APB bool default y -config SOC_I2S_NUM - int - default 1 - config SOC_I2S_HW_VERSION_1 bool default y @@ -463,38 +459,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 - config SOC_I2S_SUPPORTS_LCD_CAMERA bool default y -config SOC_I2S_MAX_DATA_WIDTH - int - default 24 - -config SOC_I2S_APLL_MIN_FREQ - int - default 250000000 - -config SOC_I2S_APLL_MAX_FREQ - int - default 500000000 - -config SOC_I2S_APLL_MIN_RATE - int - default 10675 - -config SOC_I2S_LCD_I80_VARIANT - bool - default y - config SOC_LCD_I80_SUPPORTED bool default y diff --git a/components/soc/esp32s2/include/soc/soc_caps.h b/components/soc/esp32s2/include/soc/soc_caps.h index 2c0e3a7929..1f51e7cd70 100644 --- a/components/soc/esp32s2/include/soc/soc_caps.h +++ b/components/soc/esp32s2/include/soc/soc_caps.h @@ -213,17 +213,9 @@ /*-------------------------- I2S CAPS ----------------------------------------*/ // ESP32-S2 has 1 I2S -#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_MAX_DATA_WIDTH (24) -#define SOC_I2S_APLL_MIN_FREQ (250000000) -#define SOC_I2S_APLL_MAX_FREQ (500000000) -#define SOC_I2S_APLL_MIN_RATE (10675) //in Hz, I2S Clock rate limited by hardware -#define SOC_I2S_LCD_I80_VARIANT (1) /*-------------------------- LCD CAPS ----------------------------------------*/ /* Notes: On esp32-s2, LCD intel 8080 timing is generated by I2S peripheral */ diff --git a/components/soc/esp32s2/include/soc/soc_caps_full.h b/components/soc/esp32s2/include/soc/soc_caps_full.h index 6f49d58aaa..7fe03ac855 100644 --- a/components/soc/esp32s2/include/soc/soc_caps_full.h +++ b/components/soc/esp32s2/include/soc/soc_caps_full.h @@ -33,3 +33,9 @@ /*------------------------------- Dedicated GPIO ------------------------------*/ #define _SOC_CAPS_DEDIC_GPIO_OUT_CHANS_PER_CPU 8 /*!< 8 outward channels on each CPU core */ #define _SOC_CAPS_DEDIC_GPIO_IN_CHANS_PER_CPU 8 /*!< 8 inward channels on each CPU core */ + +/*------------------------------- I2S ---------------------------------------*/ +// helper macros to access module attributes +#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances +#define _SOC_CAPS_I2S_MAX_DATA_WIDTH 24 +#define _SOC_CAPS_I2S_SUPPORT_DMA_EQUAL 1 diff --git a/components/soc/esp32s3/i2s_periph.c b/components/soc/esp32s3/i2s_periph.c index 9d040cfc54..b7fe11d9e7 100644 --- a/components/soc/esp32s3/i2s_periph.c +++ b/components/soc/esp32s3/i2s_periph.c @@ -10,7 +10,7 @@ /* Bunch of constants for every I2S peripheral: GPIO signals, irqs, hw addr of registers etc */ -const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM] = { +const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_ATTR(INST_NUM)] = { { .mck_out_sig = I2S0_MCLK_OUT_IDX, .mck_in_sig = I2S0_MCLK_IN_IDX, diff --git a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in index e26c2642c9..787a36afd7 100644 --- a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in @@ -543,22 +543,10 @@ config SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE bool default y -config SOC_I2S_NUM - int - default 2 - config SOC_I2S_HW_VERSION_2 bool default y -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 a52048b9af..b3581e0da6 100644 --- a/components/soc/esp32s3/include/soc/soc_caps.h +++ b/components/soc/esp32s3/include/soc/soc_caps.h @@ -229,10 +229,7 @@ #define SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE (1) /*-------------------------- I2S CAPS ----------------------------------------*/ -#define SOC_I2S_NUM (2U) #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) // Support to output raw PDM format data diff --git a/components/soc/esp32s3/include/soc/soc_caps_full.h b/components/soc/esp32s3/include/soc/soc_caps_full.h index d811597a3e..0c055b9d00 100644 --- a/components/soc/esp32s3/include/soc/soc_caps_full.h +++ b/components/soc/esp32s3/include/soc/soc_caps_full.h @@ -33,3 +33,7 @@ /*------------------------------- Dedicated GPIO ------------------------------*/ #define _SOC_CAPS_DEDIC_GPIO_OUT_CHANS_PER_CPU 8 /*!< 8 outward channels on each CPU core */ #define _SOC_CAPS_DEDIC_GPIO_IN_CHANS_PER_CPU 8 /*!< 8 inward channels on each CPU core */ + +/*------------------------------- I2S ---------------------------------------*/ +// helper macros to access module attributes +#define _SOC_CAPS_I2S_INST_NUM 2 // Number of I2S instances diff --git a/components/soc/include/soc/i2s_periph.h b/components/soc/include/soc/i2s_periph.h index 0dfc4a1196..f94770db9f 100644 --- a/components/soc/include/soc/i2s_periph.h +++ b/components/soc/include/soc/i2s_periph.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,21 +8,24 @@ #include "soc/soc.h" #include "soc/interrupts.h" #include "soc/soc_caps.h" +#include "soc/soc_caps_full.h" #include "soc/regdma.h" -#if SOC_I2S_SUPPORT_SLEEP_RETENTION +#if SOC_HAS(PAU) #include "soc/retention_periph_defs.h" #endif -#if SOC_I2S_SUPPORTED +#if SOC_HAS(I2S) #include "soc/i2s_struct.h" #include "soc/i2s_reg.h" #endif +#define SOC_I2S_ATTR(_attr) SOC_MODULE_ATTR(I2S, _attr) + #ifdef __cplusplus extern "C" { #endif -#if SOC_I2S_SUPPORTED +#if SOC_HAS(I2S) /* Stores a bunch of per-I2S-peripheral data. */ @@ -57,23 +60,22 @@ typedef struct { const uint8_t irq; } i2s_signal_conn_t; -extern const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM]; +extern const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_ATTR(INST_NUM)]; #if SOC_LP_I2S_SUPPORTED extern const i2s_signal_conn_t lp_i2s_periph_signal[SOC_LP_I2S_NUM]; #endif -#endif // SOC_I2S_SUPPORTED - -#if SOC_I2S_SUPPORT_SLEEP_RETENTION +#if SOC_HAS(PAU) typedef struct { const periph_retention_module_t retention_module; const regdma_entries_config_t *entry_array; uint32_t array_size; } i2s_reg_retention_info_t; -extern const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_NUM]; -#endif // SOC_I2S_SUPPORT_SLEEP_RETENTION +extern const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_ATTR(INST_NUM)]; +#endif // SOC_HAS(PAU) +#endif // SOC_HAS(I2S) #ifdef __cplusplus } diff --git a/components/soc/include/soc/lcd_periph.h b/components/soc/include/soc/lcd_periph.h index 3bcf50e3c5..cabc94f51b 100644 --- a/components/soc/include/soc/lcd_periph.h +++ b/components/soc/include/soc/lcd_periph.h @@ -8,6 +8,7 @@ #include "soc/soc_caps.h" #include "soc/periph_defs.h" +#include "soc/soc_caps_full.h" #ifdef __cplusplus extern "C" { @@ -50,7 +51,7 @@ typedef struct { struct { const periph_module_t module; const int irq_id; - const int data_sigs[SOC_I2S_MAX_DATA_WIDTH]; + const int data_sigs[SOC_MODULE_ATTR(I2S, MAX_DATA_WIDTH)]; const int wr_sig; } buses[SOC_LCD_I80_BUSES]; } lcd_i2s_signal_conn_t; diff --git a/docs/en/migration-guides/release-5.x/5.0/peripherals.rst b/docs/en/migration-guides/release-5.x/5.0/peripherals.rst index b625c95f9e..6307800887 100644 --- a/docs/en/migration-guides/release-5.x/5.0/peripherals.rst +++ b/docs/en/migration-guides/release-5.x/5.0/peripherals.rst @@ -499,7 +499,7 @@ LCD - The :cpp:type:`i2s_chan_handle_t` handle type is used to uniquely identify I2S channels. All the APIs require the channel handle and users need to maintain the channel handles by themselves. - On the ESP32-C3 and ESP32-S3, TX and RX channels in the same controller can be configured to different clocks or modes. - However, on the ESP32 and ESP32-S2, the TX and RX channels of the same controller still share some hardware resources. Thus, configurations may cause one channel to affect another channel in the same controller. - - The channels can be registered to an available I2S controller automatically by setting :cpp:enumerator:`i2s_port_t::I2S_NUM_AUTO` as I2S port ID which causes the driver to search for the available TX/RX channels. However, the driver also supports registering channels to a specific port. + - The channels can be registered to an available I2S controller automatically by setting ``I2S_NUM_AUTO`` as I2S port ID which causes the driver to search for the available TX/RX channels. However, the driver also supports registering channels to a specific port. - In order to distinguish between TX/RX channels and sound channels, the term "channel" in the context of the I2S driver only refers to TX/RX channels. Meanwhile, sound channels are referred to as "slots". I2S Mode Categorization diff --git a/docs/en/migration-guides/release-6.x/6.0/peripherals.rst b/docs/en/migration-guides/release-6.x/6.0/peripherals.rst index d7a67ffcf0..d3bca07ce0 100644 --- a/docs/en/migration-guides/release-6.x/6.0/peripherals.rst +++ b/docs/en/migration-guides/release-6.x/6.0/peripherals.rst @@ -264,6 +264,11 @@ Touch Sensor The ``touch_sensor_sample_config_t::bypass_shield_output`` member for version 3 touch sensor has been removed because it is not supported in the version 3 hardware. +I2S +--- + +- ``i2s_port_t`` type has been removed. Please use ``int`` type instead. Its enum items ``I2S_NUM_0``, ``I2S_NUM_1``, ``I2S_NUM_2`` and ``I2S_NUM_AUTO`` have been replaced by macro definitions to ensure compatibility. + USB --- diff --git a/docs/zh_CN/migration-guides/release-5.x/5.0/peripherals.rst b/docs/zh_CN/migration-guides/release-5.x/5.0/peripherals.rst index 813163be5a..c7161fb0cc 100644 --- a/docs/zh_CN/migration-guides/release-5.x/5.0/peripherals.rst +++ b/docs/zh_CN/migration-guides/release-5.x/5.0/peripherals.rst @@ -499,7 +499,7 @@ LCD - :cpp:type:`i2s_chan_handle_t` 句柄类型用于唯一地识别 I2S 通道。所有的 API 都需要该通道句柄,用户需要对这些通道句柄进行维护。 - 对于 ESP32-C3 和 ESP32-S3,同一个控制器中的发送通道和接收通道可以配置为不同的时钟或不同的模式。 - 但是对于 ESP32 和 ESP32-S2, 同一个控制器中的发送通道和接收通道共享某些硬件资源。因此,配置可能会造成一个通道影响同一个控制器中的另一个通道。 - - 通过将 :cpp:enumerator:`i2s_port_t::I2S_NUM_AUTO` 设置为 I2S 端口 ID,驱动会搜索可用的发送/接收通道,之后通道会被自动注册到可用的 I2S 控制器上。但是,驱动仍然支持将通道注册到一个特定的端口上。 + - 通过将 ``I2S_NUM_AUTO`` 设置为 I2S 端口 ID,驱动会搜索可用的发送/接收通道,之后通道会被自动注册到可用的 I2S 控制器上。但是,驱动仍然支持将通道注册到一个特定的端口上。 - 为区分发送/接收通道和声音通道,在更新后的驱动中,“通道 (channel)”一词仅代表发送/接收通道,用“声道 (slot)”来表示声音通道。 I2S 模式分类 diff --git a/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst b/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst index 991dfc530f..8c264b19af 100644 --- a/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst +++ b/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst @@ -263,3 +263,8 @@ Touch Sensor ------------ 第三版触摸传感器的驱动配置项 ``touch_sensor_sample_config_t::bypass_shield_output`` 已被移除,因为第三版触摸传感器硬件已不支持该功能。 + +I2S +--- + +- ``i2s_port_t`` 类型已被移除。请使用 ``int`` 类型代替。该类型原有的 enum 项 ``I2S_NUM_0``,``I2S_NUM_1``,``I2S_NUM_2`` 和 ``I2S_NUM_AUTO`` 已用宏定义代替,以保证兼容性。