diff --git a/components/esp_driver_tsens/CMakeLists.txt b/components/esp_driver_tsens/CMakeLists.txt index 30b2f8429f3..92e887c75f0 100644 --- a/components/esp_driver_tsens/CMakeLists.txt +++ b/components/esp_driver_tsens/CMakeLists.txt @@ -1,3 +1,5 @@ +idf_build_get_property(target IDF_TARGET) + set(srcs) set(priv_req efuse) set(public_include "include") @@ -6,10 +8,15 @@ if(CONFIG_SOC_TEMP_SENSOR_SUPPORTED) if(CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_ETM) list(APPEND srcs "src/temperature_sensor_etm.c") endif() + if(CONFIG_SOC_PAU_SUPPORTED AND CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION + AND CONFIG_SOC_TEMPERATURE_SENSOR_UNDER_PD_TOP_DOMAIN) + list(APPEND srcs "${target}/temperature_sensor_retention.c") + endif() endif() idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${public_include} + PRIV_INCLUDE_DIRS "src" REQUIRES esp_hal_ana_conv PRIV_REQUIRES ${priv_req} ) diff --git a/components/esp_driver_tsens/esp32c5/temperature_sensor_retention.c b/components/esp_driver_tsens/esp32c5/temperature_sensor_retention.c new file mode 100644 index 00000000000..1020c3994c4 --- /dev/null +++ b/components/esp_driver_tsens/esp32c5/temperature_sensor_retention.c @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include "soc/regdma.h" +#include "soc/apb_saradc_reg.h" +#include "temperature_sensor_private.h" + +// Temperature sensor sleep retention entries +// Temperature sensor registers require set the reg_update bit to make the configuration take effect + +/* Temperature sensor Registers Context + Include: APB_SARADC_INT_ENA_REG / + APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG +*/ +#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5 +#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG +static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0}; +static const regdma_entries_config_t temperature_sensor_regs_entries[] = { + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \ + .owner = ENTRY(0) | ENTRY(2) + }, \ +}; + +const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = { + .link_list = temperature_sensor_regs_entries, + .link_num = ARRAY_SIZE(temperature_sensor_regs_entries), + .module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR, +}; diff --git a/components/esp_driver_tsens/esp32c6/temperature_sensor_retention.c b/components/esp_driver_tsens/esp32c6/temperature_sensor_retention.c new file mode 100644 index 00000000000..1020c3994c4 --- /dev/null +++ b/components/esp_driver_tsens/esp32c6/temperature_sensor_retention.c @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include "soc/regdma.h" +#include "soc/apb_saradc_reg.h" +#include "temperature_sensor_private.h" + +// Temperature sensor sleep retention entries +// Temperature sensor registers require set the reg_update bit to make the configuration take effect + +/* Temperature sensor Registers Context + Include: APB_SARADC_INT_ENA_REG / + APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG +*/ +#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5 +#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG +static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0}; +static const regdma_entries_config_t temperature_sensor_regs_entries[] = { + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \ + .owner = ENTRY(0) | ENTRY(2) + }, \ +}; + +const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = { + .link_list = temperature_sensor_regs_entries, + .link_num = ARRAY_SIZE(temperature_sensor_regs_entries), + .module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR, +}; diff --git a/components/esp_driver_tsens/esp32c61/temperature_sensor_retention.c b/components/esp_driver_tsens/esp32c61/temperature_sensor_retention.c new file mode 100644 index 00000000000..db01b5fe538 --- /dev/null +++ b/components/esp_driver_tsens/esp32c61/temperature_sensor_retention.c @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include "soc/regdma.h" +#include "soc/apb_saradc_reg.h" +#include "temperature_sensor_private.h" + +// Temperature sensor sleep retention entries +// Temperature sensor registers require set the reg_update bit to make the configuration take effect + +/* Temperature sensor Registers Context + Include: SARADC_INT_ENA_REG / + APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG +*/ +#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5 +#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE SARADC_INT_ENA_REG +static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0}; +static const regdma_entries_config_t temperature_sensor_regs_entries[] = { + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \ + .owner = ENTRY(0) | ENTRY(2) + }, \ +}; + +const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = { + .link_list = temperature_sensor_regs_entries, + .link_num = ARRAY_SIZE(temperature_sensor_regs_entries), + .module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR, +}; diff --git a/components/esp_driver_tsens/esp32h2/temperature_sensor_retention.c b/components/esp_driver_tsens/esp32h2/temperature_sensor_retention.c new file mode 100644 index 00000000000..1020c3994c4 --- /dev/null +++ b/components/esp_driver_tsens/esp32h2/temperature_sensor_retention.c @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include "soc/regdma.h" +#include "soc/apb_saradc_reg.h" +#include "temperature_sensor_private.h" + +// Temperature sensor sleep retention entries +// Temperature sensor registers require set the reg_update bit to make the configuration take effect + +/* Temperature sensor Registers Context + Include: APB_SARADC_INT_ENA_REG / + APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG +*/ +#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5 +#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG +static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0}; +static const regdma_entries_config_t temperature_sensor_regs_entries[] = { + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \ + .owner = ENTRY(0) | ENTRY(2) + }, \ +}; + +const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = { + .link_list = temperature_sensor_regs_entries, + .link_num = ARRAY_SIZE(temperature_sensor_regs_entries), + .module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR, +}; diff --git a/components/esp_driver_tsens/esp32h4/temperature_sensor_retention.c b/components/esp_driver_tsens/esp32h4/temperature_sensor_retention.c new file mode 100644 index 00000000000..1020c3994c4 --- /dev/null +++ b/components/esp_driver_tsens/esp32h4/temperature_sensor_retention.c @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include "soc/regdma.h" +#include "soc/apb_saradc_reg.h" +#include "temperature_sensor_private.h" + +// Temperature sensor sleep retention entries +// Temperature sensor registers require set the reg_update bit to make the configuration take effect + +/* Temperature sensor Registers Context + Include: APB_SARADC_INT_ENA_REG / + APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG +*/ +#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5 +#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG +static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0}; +static const regdma_entries_config_t temperature_sensor_regs_entries[] = { + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \ + .owner = ENTRY(0) | ENTRY(2) + }, \ +}; + +const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = { + .link_list = temperature_sensor_regs_entries, + .link_num = ARRAY_SIZE(temperature_sensor_regs_entries), + .module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR, +}; diff --git a/components/esp_driver_tsens/src/temperature_sensor.c b/components/esp_driver_tsens/src/temperature_sensor.c index 7a11d7d06a9..cdbbb22f46d 100644 --- a/components/esp_driver_tsens/src/temperature_sensor.c +++ b/components/esp_driver_tsens/src/temperature_sensor.c @@ -145,9 +145,6 @@ esp_err_t temperature_sensor_install(const temperature_sensor_config_t *tsens_co #if !SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(tsens_config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep"); -#if SOC_PM_SUPPORT_TOP_PD - esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15648 -#endif #endif // SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION #if SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION && !SOC_TEMPERATURE_SENSOR_UNDER_PD_TOP_DOMAIN diff --git a/components/esp_driver_tsens/src/temperature_sensor_private.h b/components/esp_driver_tsens/src/temperature_sensor_private.h index ef1a4991113..81210b45a4d 100644 --- a/components/esp_driver_tsens/src/temperature_sensor_private.h +++ b/components/esp_driver_tsens/src/temperature_sensor_private.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -7,11 +7,16 @@ #pragma once #include +#include "soc/soc_caps.h" #include "hal/temperature_sensor_periph.h" #include "hal/temperature_sensor_types.h" #include "driver/temperature_sensor.h" #include "esp_intr_alloc.h" #include "sdkconfig.h" +#if SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION +#include "soc/regdma.h" +#include "soc/retention_periph_defs.h" +#endif #ifdef __cplusplus extern "C" { @@ -33,6 +38,18 @@ typedef enum { // Use retention link only when the target supports sleep retention and PM is enabled #define TEMPERATURE_SENSOR_USE_RETENTION_LINK (SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_TEMPERATURE_SENSOR_UNDER_PD_TOP_DOMAIN) +#if SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION +// Sleep-retention RegDMA link descriptor exported by per-target +// `/temperature_sensor_retention.c`. +typedef struct { + const regdma_entries_config_t *link_list; + uint32_t link_num; + periph_retention_module_t module_id; +} temperature_sensor_reg_ctx_link_t; + +extern const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention; +#endif // SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION + typedef struct temperature_sensor_obj_t temperature_sensor_obj_t; struct temperature_sensor_obj_t { diff --git a/components/esp_driver_tsens/test_apps/.build-test-rules.yml b/components/esp_driver_tsens/test_apps/.build-test-rules.yml index e9415242372..5a2b5c628e7 100644 --- a/components/esp_driver_tsens/test_apps/.build-test-rules.yml +++ b/components/esp_driver_tsens/test_apps/.build-test-rules.yml @@ -3,10 +3,6 @@ components/esp_driver_tsens/test_apps/temperature_sensor: disable: - if: SOC_TEMP_SENSOR_SUPPORTED != 1 - disable_test: - - if: IDF_TARGET in ["esp32h4"] - temporary: true - reason: cannot pass # TODO: IDF-15617 depends_components: - esp_driver_tsens - esp_hal_ana_conv diff --git a/components/esp_driver_tsens/test_apps/temperature_sensor/pytest_temperature_sensor.py b/components/esp_driver_tsens/test_apps/temperature_sensor/pytest_temperature_sensor.py index ed08be16625..ce7c315b4ba 100644 --- a/components/esp_driver_tsens/test_apps/temperature_sensor/pytest_temperature_sensor.py +++ b/components/esp_driver_tsens/test_apps/temperature_sensor/pytest_temperature_sensor.py @@ -20,7 +20,6 @@ from pytest_embedded_idf.utils import soc_filtered_targets soc_filtered_targets('SOC_TEMP_SENSOR_SUPPORTED == 1 and IDF_TARGET not in ["esp32c5"]'), indirect=['target'], ) -@pytest.mark.temp_skip_ci(targets=['esp32h4'], reason='cannot pass') # TODO: IDF-15617 def test_temperature_sensor_driver(dut: Dut) -> None: dut.run_all_single_board_cases() @@ -51,7 +50,9 @@ def test_temperature_sensor_driver_esp32c5_rev1(dut: Dut) -> None: ], indirect=True, ) -@idf_parametrize('target', ['esp32c6', 'esp32h2', 'esp32p4', 'esp32c5', 'esp32c61', 'esp32s31'], indirect=['target']) +@idf_parametrize( + 'target', ['esp32c6', 'esp32h2', 'esp32p4', 'esp32c5', 'esp32c61', 'esp32s31', 'esp32h4'], indirect=['target'] +) def test_temperature_sensor_cbs(dut: Dut) -> None: dut.run_all_single_board_cases() diff --git a/components/esp_hal_ana_conv/esp32c5/temperature_sensor_periph.c b/components/esp_hal_ana_conv/esp32c5/temperature_sensor_periph.c index 2d359634fed..e3f1fefcf38 100644 --- a/components/esp_hal_ana_conv/esp32c5/temperature_sensor_periph.c +++ b/components/esp_hal_ana_conv/esp32c5/temperature_sensor_periph.c @@ -1,13 +1,10 @@ /* - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ -#include -#include "soc/regdma.h" #include "hal/temperature_sensor_periph.h" -#include "soc/apb_saradc_reg.h" const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM] = { /*Offset reg_val min max error */ @@ -17,26 +14,3 @@ const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_S { 1, 11, -30, 50, 2}, { 2, 10, -40, 20, 3}, }; - -// Temperature sensor sleep retention entries -// Temperature sensor registers require set the reg_update bit to make the configuration take effect - -/* Temperature sensor Registers Context - Include: APB_SARADC_INT_ENA_REG / - APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG -*/ -#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5 -#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG -static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0}; -static const regdma_entries_config_t temperature_sensor_regs_entries[] = { - [0] = { - .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \ - .owner = ENTRY(0) | ENTRY(2) - }, \ -}; - -const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = { - .link_list = temperature_sensor_regs_entries, - .link_num = ARRAY_SIZE(temperature_sensor_regs_entries), - .module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR, -}; diff --git a/components/esp_hal_ana_conv/esp32c6/temperature_sensor_periph.c b/components/esp_hal_ana_conv/esp32c6/temperature_sensor_periph.c index 1f4af3135a0..e5525076c55 100644 --- a/components/esp_hal_ana_conv/esp32c6/temperature_sensor_periph.c +++ b/components/esp_hal_ana_conv/esp32c6/temperature_sensor_periph.c @@ -1,13 +1,10 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ -#include -#include "soc/regdma.h" #include "hal/temperature_sensor_periph.h" -#include "soc/apb_saradc_reg.h" const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM] = { /*Offset reg_val min max error */ @@ -17,26 +14,3 @@ const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_S { 1, 11, -30, 50, 2}, { 2, 10, -40, 20, 3}, }; - -// Temperature sensor sleep retention entries -// Temperature sensor registers require set the reg_update bit to make the configuration take effect - -/* Temperature sensor Registers Context - Include: APB_SARADC_INT_ENA_REG / - APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG -*/ -#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5 -#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG -static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0}; -static const regdma_entries_config_t temperature_sensor_regs_entries[] = { - [0] = { - .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \ - .owner = ENTRY(0) | ENTRY(2) - }, \ -}; - -const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = { - .link_list = temperature_sensor_regs_entries, - .link_num = ARRAY_SIZE(temperature_sensor_regs_entries), - .module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR, -}; diff --git a/components/esp_hal_ana_conv/esp32c61/temperature_sensor_periph.c b/components/esp_hal_ana_conv/esp32c61/temperature_sensor_periph.c index 3e0e2d70d70..e3f1fefcf38 100644 --- a/components/esp_hal_ana_conv/esp32c61/temperature_sensor_periph.c +++ b/components/esp_hal_ana_conv/esp32c61/temperature_sensor_periph.c @@ -1,13 +1,10 @@ /* - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ -#include -#include "soc/regdma.h" #include "hal/temperature_sensor_periph.h" -#include "soc/apb_saradc_reg.h" const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM] = { /*Offset reg_val min max error */ @@ -17,26 +14,3 @@ const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_S { 1, 11, -30, 50, 2}, { 2, 10, -40, 20, 3}, }; - -// Temperature sensor sleep retention entries -// Temperature sensor registers require set the reg_update bit to make the configuration take effect - -/* Temperature sensor Registers Context - Include: SARADC_INT_ENA_REG / - APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG -*/ -#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5 -#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE SARADC_INT_ENA_REG -static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0}; -static const regdma_entries_config_t temperature_sensor_regs_entries[] = { - [0] = { - .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \ - .owner = ENTRY(0) | ENTRY(2) - }, \ -}; - -const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = { - .link_list = temperature_sensor_regs_entries, - .link_num = ARRAY_SIZE(temperature_sensor_regs_entries), - .module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR, -}; diff --git a/components/esp_hal_ana_conv/esp32h2/temperature_sensor_periph.c b/components/esp_hal_ana_conv/esp32h2/temperature_sensor_periph.c index 2819b947d98..ebf84b7ec00 100644 --- a/components/esp_hal_ana_conv/esp32h2/temperature_sensor_periph.c +++ b/components/esp_hal_ana_conv/esp32h2/temperature_sensor_periph.c @@ -1,13 +1,10 @@ /* - * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ -#include -#include "soc/regdma.h" #include "hal/temperature_sensor_periph.h" -#include "soc/apb_saradc_reg.h" const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM] = { /*Offset reg_val min max error */ @@ -17,26 +14,3 @@ const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_S { 1, 11, -30, 50, 2}, { 2, 10, -40, 20, 3}, }; - -// Temperature sensor sleep retention entries -// Temperature sensor registers require set the reg_update bit to make the configuration take effect - -/* Temperature sensor Registers Context - Include: APB_SARADC_INT_ENA_REG / - APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG -*/ -#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5 -#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG -static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0}; -static const regdma_entries_config_t temperature_sensor_regs_entries[] = { - [0] = { - .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \ - .owner = ENTRY(0) | ENTRY(2) - }, \ -}; - -const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = { - .link_list = temperature_sensor_regs_entries, - .link_num = ARRAY_SIZE(temperature_sensor_regs_entries), - .module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR, -}; diff --git a/components/esp_hal_ana_conv/esp32h4/include/hal/temperature_sensor_ll.h b/components/esp_hal_ana_conv/esp32h4/include/hal/temperature_sensor_ll.h index 0374c77400c..b8d93fede8f 100644 --- a/components/esp_hal_ana_conv/esp32h4/include/hal/temperature_sensor_ll.h +++ b/components/esp_hal_ana_conv/esp32h4/include/hal/temperature_sensor_ll.h @@ -117,6 +117,7 @@ static inline void temperature_sensor_ll_clk_sel(temperature_sensor_clk_src_t cl * * @param tsens_dac ``reg_val`` in table ``temperature_sensor_attributes`` */ +__attribute__((always_inline)) static inline void temperature_sensor_ll_set_range(uint32_t range) { REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_TSENS_DAC, range); @@ -140,6 +141,7 @@ static inline uint32_t temperature_sensor_ll_get_raw_value(void) * * @return uint32_t offset value */ +__attribute__((always_inline)) static inline uint32_t temperature_sensor_ll_get_offset(void) { return REGI2C_READ_MASK(I2C_SAR_ADC, I2C_SARADC_TSENS_DAC); diff --git a/components/esp_hal_ana_conv/esp32h4/temperature_sensor_periph.c b/components/esp_hal_ana_conv/esp32h4/temperature_sensor_periph.c index f09c7c18cd6..fbc8eaa0786 100644 --- a/components/esp_hal_ana_conv/esp32h4/temperature_sensor_periph.c +++ b/components/esp_hal_ana_conv/esp32h4/temperature_sensor_periph.c @@ -4,10 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include -#include "soc/regdma.h" #include "hal/temperature_sensor_periph.h" -#include "soc/apb_saradc_reg.h" const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM] = { /*Offset reg_val min max error */ diff --git a/components/esp_hal_ana_conv/include/hal/temperature_sensor_periph.h b/components/esp_hal_ana_conv/include/hal/temperature_sensor_periph.h index b3765388fab..2dce5734d4b 100644 --- a/components/esp_hal_ana_conv/include/hal/temperature_sensor_periph.h +++ b/components/esp_hal_ana_conv/include/hal/temperature_sensor_periph.h @@ -1,16 +1,11 @@ /* - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include "soc/regdma.h" -#if SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION -#include "soc/retention_periph_defs.h" -#endif - #ifdef __cplusplus extern "C" { #endif @@ -27,16 +22,6 @@ typedef struct { extern const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM]; -#if SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION -typedef struct { - const regdma_entries_config_t *link_list; - uint32_t link_num; - periph_retention_module_t module_id; -} temperature_sensor_reg_ctx_link_t; - -extern const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention; -#endif // SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION - #ifdef __cplusplus } #endif diff --git a/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in index e5b8dcd8604..89d3945d08d 100644 --- a/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in @@ -1279,6 +1279,14 @@ config SOC_TEMPERATURE_SENSOR_INTR_SUPPORT bool default y +config SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION + bool + default y + +config SOC_TEMPERATURE_SENSOR_UNDER_PD_TOP_DOMAIN + bool + default y + config SOC_TOUCH_SENSOR_VERSION int default 3 diff --git a/components/soc/esp32h4/include/soc/soc_caps.h b/components/soc/esp32h4/include/soc/soc_caps.h index 5e13338ec1d..efc20f9d35d 100644 --- a/components/soc/esp32h4/include/soc/soc_caps.h +++ b/components/soc/esp32h4/include/soc/soc_caps.h @@ -538,7 +538,8 @@ #define SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC (1) #define SOC_TEMPERATURE_SENSOR_SUPPORT_XTAL (1) #define SOC_TEMPERATURE_SENSOR_INTR_SUPPORT (1) -// #define SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION (1) +#define SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION (1) +#define SOC_TEMPERATURE_SENSOR_UNDER_PD_TOP_DOMAIN (1) /*-------------------------- TOUCH SENSOR CAPS -------------------------------*/ #define SOC_TOUCH_SENSOR_VERSION (3) /*!< Hardware version of touch sensor */