From 74887d81c96401e2e5c8096876e9052c6024c8b1 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Mon, 6 Nov 2023 16:18:33 +0800 Subject: [PATCH 1/2] refactor(system): removed dependency on driver from g1 components esp-system and esp-hw-support, and the rest of the g1 components, now only depend on esp_driver_spi and esp_driver_gpio. Removing the rest of the driver components from g1 builds. --- components/esp_hw_support/CMakeLists.txt | 3 +-- components/esp_hw_support/sleep_modes.c | 9 ++------- components/esp_system/CMakeLists.txt | 4 ++-- tools/test_apps/system/g1_components/CMakeLists.txt | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt index f996e17e52..1324a65456 100644 --- a/components/esp_hw_support/CMakeLists.txt +++ b/components/esp_hw_support/CMakeLists.txt @@ -51,8 +51,7 @@ if(NOT BOOTLOADER_BUILD) endif() # [refactor-todo] - list(APPEND priv_requires driver # for UART (by sleep_modes) - esp_driver_gpio # for GPIO and RTC (by sleep_gpio and sleep_modes) + list(APPEND priv_requires esp_driver_gpio # for GPIO and RTC (by sleep_gpio and sleep_modes) esp_timer esp_pm) diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 6f8d6a07ef..e34526661e 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -37,8 +37,6 @@ #include "hal/rtc_hal.h" #endif -#include "driver/uart.h" - #include "soc/rtc.h" #include "soc/soc_caps.h" #include "regi2c_ctrl.h" //For `REGI2C_ANA_CALI_PD_WORKAROUND`, temp @@ -49,8 +47,6 @@ #include "hal/uart_hal.h" #if SOC_TOUCH_SENSOR_SUPPORTED #include "hal/touch_sensor_hal.h" -#include "driver/touch_sensor.h" -#include "driver/touch_sensor_common.h" #endif #include "hal/clk_gate_ll.h" @@ -1423,9 +1419,8 @@ touch_pad_t esp_sleep_get_touchpad_wakeup_status(void) return TOUCH_PAD_MAX; } touch_pad_t pad_num; - esp_err_t ret = touch_pad_get_wakeup_status(&pad_num); //TODO 723diff commit id:fda9ada1b - assert(ret == ESP_OK && "wakeup reason is RTC_TOUCH_TRIG_EN but SENS_TOUCH_MEAS_EN is zero"); - return (ret == ESP_OK) ? pad_num : TOUCH_PAD_MAX; + touch_hal_get_wakeup_status(&pad_num); + return pad_num; } #endif // SOC_TOUCH_SENSOR_SUPPORTED diff --git a/components/esp_system/CMakeLists.txt b/components/esp_system/CMakeLists.txt index c63a27df0b..bee467e389 100644 --- a/components/esp_system/CMakeLists.txt +++ b/components/esp_system/CMakeLists.txt @@ -63,11 +63,11 @@ else() # [refactor-todo] requirements due to init code, # should be removable once using component init functions # link-time registration is used. - # [refactor-todo] requires "driver" for headers: + # [refactor-todo] requires "esp_driver_spi" for headers: # - spi_common_internal.h # [refactor-todo] esp_partition required for virtual efuse # init code. Move to esp_efuse component. - pthread bootloader_support efuse driver esp_partition + pthread bootloader_support efuse esp_driver_spi esp_partition LDFRAGMENTS "linker.lf" "app.lf") add_subdirectory(port) diff --git a/tools/test_apps/system/g1_components/CMakeLists.txt b/tools/test_apps/system/g1_components/CMakeLists.txt index ef31eac5b8..894d696d9d 100644 --- a/tools/test_apps/system/g1_components/CMakeLists.txt +++ b/tools/test_apps/system/g1_components/CMakeLists.txt @@ -35,7 +35,7 @@ set(extra_components_which_shouldnt_be_included cxx # [refactor-todo]: driver is a dependency of esp_pm, spi_flash, vfs, esp_wifi # all of these should be removed from G1 except for spi_flash. - driver esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm + esp_driver_gpio esp_driver_spi # esp_app_format is dependency of bootloader_support, app_update esp_app_format # esp_bootloader_format is dependency of bootloader_support, app_update From d293ad94bde49ca96ec2ceb0c7a87a844134d2b4 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Sat, 11 Nov 2023 15:23:41 +0800 Subject: [PATCH 2/2] feat(pm): removed dependency on driver component --- components/driver/uart/uart.c | 2 +- .../include/esp_private/uart_share_hw_ctrl.h} | 0 components/esp_pm/CMakeLists.txt | 2 +- components/esp_pm/pm_impl.c | 13 ++++++++++--- .../esp_system_unity_tests/main/test_sleep.c | 2 +- components/ulp/lp_core/lp_core_uart.c | 2 +- 6 files changed, 14 insertions(+), 7 deletions(-) rename components/{driver/include/esp_private/uart_private.h => esp_hw_support/include/esp_private/uart_share_hw_ctrl.h} (100%) diff --git a/components/driver/uart/uart.c b/components/driver/uart/uart.c index 644977f5c8..a7a643902b 100644 --- a/components/driver/uart/uart.c +++ b/components/driver/uart/uart.c @@ -27,7 +27,7 @@ #include "driver/rtc_io.h" #include "driver/uart_select.h" #include "driver/lp_io.h" -#include "esp_private/uart_private.h" +#include "esp_private/uart_share_hw_ctrl.h" #include "esp_private/periph_ctrl.h" #include "esp_clk_tree.h" #include "sdkconfig.h" diff --git a/components/driver/include/esp_private/uart_private.h b/components/esp_hw_support/include/esp_private/uart_share_hw_ctrl.h similarity index 100% rename from components/driver/include/esp_private/uart_private.h rename to components/esp_hw_support/include/esp_private/uart_share_hw_ctrl.h diff --git a/components/esp_pm/CMakeLists.txt b/components/esp_pm/CMakeLists.txt index a4b414e99b..27ce9ada3c 100644 --- a/components/esp_pm/CMakeLists.txt +++ b/components/esp_pm/CMakeLists.txt @@ -6,5 +6,5 @@ endif() idf_component_register(SRCS "pm_locks.c" "pm_trace.c" "pm_impl.c" INCLUDE_DIRS include - PRIV_REQUIRES esp_system driver esp_driver_gpio esp_timer + PRIV_REQUIRES esp_system esp_driver_gpio esp_timer LDFRAGMENTS linker.lf) diff --git a/components/esp_pm/pm_impl.c b/components/esp_pm/pm_impl.c index bbf4eea7b6..2746965238 100644 --- a/components/esp_pm/pm_impl.c +++ b/components/esp_pm/pm_impl.c @@ -15,14 +15,15 @@ #include "esp_pm.h" #include "esp_log.h" #include "esp_cpu.h" +#include "esp_clk_tree.h" +#include "soc/soc_caps.h" #include "esp_private/crosscore_int.h" -#include "esp_private/uart_private.h" +#include "esp_private/periph_ctrl.h" #include "soc/rtc.h" #include "hal/uart_ll.h" #include "hal/uart_types.h" -#include "driver/uart.h" #include "driver/gpio.h" #include "freertos/FreeRTOS.h" @@ -43,11 +44,17 @@ #include "esp_private/sleep_cpu.h" #include "esp_private/sleep_gpio.h" #include "esp_private/sleep_modem.h" +#include "esp_private/uart_share_hw_ctrl.h" #include "esp_sleep.h" #include "esp_memory_utils.h" #include "sdkconfig.h" +#if SOC_PERIPH_CLK_CTRL_SHARED +#define HP_UART_SRC_CLK_ATOMIC() PERIPH_RCC_ATOMIC() +#else +#define HP_UART_SRC_CLK_ATOMIC() +#endif #define MHZ (1000000) @@ -903,7 +910,7 @@ void esp_pm_impl_init(void) uart_ll_set_sclk(UART_LL_GET_HW(CONFIG_ESP_CONSOLE_UART_NUM), (soc_module_clk_t)clk_source); } uint32_t sclk_freq; - esp_err_t err = uart_get_sclk_freq(clk_source, &sclk_freq); + esp_err_t err = esp_clk_tree_src_get_freq_hz((soc_module_clk_t)clk_source, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &sclk_freq); assert(err == ESP_OK); HP_UART_SRC_CLK_ATOMIC() { uart_ll_set_baudrate(UART_LL_GET_HW(CONFIG_ESP_CONSOLE_UART_NUM), CONFIG_ESP_CONSOLE_UART_BAUDRATE, sclk_freq); diff --git a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c index e5cb5a3176..22ec2f21af 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c +++ b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c @@ -26,7 +26,7 @@ #include "esp_rom_sys.h" #include "esp_timer.h" #include "esp_private/esp_clk.h" -#include "esp_private/uart_private.h" +#include "esp_private/uart_share_hw_ctrl.h" #include "esp_random.h" #include "nvs_flash.h" #include "nvs.h" diff --git a/components/ulp/lp_core/lp_core_uart.c b/components/ulp/lp_core/lp_core_uart.c index 4a4fad93a1..eba6bbc2d5 100644 --- a/components/ulp/lp_core/lp_core_uart.c +++ b/components/ulp/lp_core/lp_core_uart.c @@ -13,7 +13,7 @@ #include "hal/rtc_io_types.h" #include "esp_clk_tree.h" #include "esp_private/periph_ctrl.h" -#include "esp_private/uart_private.h" +#include "esp_private/uart_share_hw_ctrl.h" #define LP_UART_PORT_NUM LP_UART_NUM_0 #define LP_UART_TX_IDLE_NUM_DEFAULT (0U)