1idf_build_get_property(target IDF_TARGET)
2
3# On Linux, we only support a few features, hence this simple component registration
4if(${target} STREQUAL "linux")
5    idf_component_register(SRCS "port/linux/esp_random.c"
6                                 "port/linux/chip_info.c"
7                           INCLUDE_DIRS "include")
8    return()
9endif()
10
11set(requires soc)
12# only esp_hw_support/adc_share_hw_ctrl.c requires efuse component
13set(priv_requires efuse spi_flash bootloader_support)
14
15if(${target} STREQUAL "esp32c6")
16    list(APPEND priv_requires hal)
17endif()
18
19set(srcs "cpu.c" "port/${IDF_TARGET}/esp_cpu_intr.c" "esp_memory_utils.c" "port/${IDF_TARGET}/cpu_region_protect.c")
20if(NOT BOOTLOADER_BUILD)
21    list(APPEND srcs "esp_clk.c"
22                     "clk_ctrl_os.c"
23                     "hw_random.c"
24                     "intr_alloc.c"
25                     "mac_addr.c"
26                     "periph_ctrl.c"
27                     "revision.c"
28                     "rtc_module.c"
29                     "sleep_modes.c"
30                     "sleep_console.c"
31                     "sleep_gpio.c"
32                     "sleep_event.c"
33                     "sleep_modem.c"
34                     "regi2c_ctrl.c"
35                     "esp_gpio_reserve.c"
36                     "sar_periph_ctrl_common.c"
37                     "port/${target}/io_mux.c"
38                     "port/${target}/esp_clk_tree.c"
39                     "port/esp_clk_tree_common.c")
40
41    if(CONFIG_SOC_ADC_SUPPORTED)
42        list(APPEND srcs "adc_share_hw_ctrl.c")
43    endif()
44
45    if(CONFIG_SOC_PM_SUPPORT_CPU_PD)
46        list(APPEND srcs "sleep_cpu.c")
47    endif()
48
49    if(CONFIG_SOC_PAU_SUPPORTED)
50        list(APPEND srcs "sleep_retention.c"  "sleep_system_peripheral.c" "sleep_clock.c")
51    endif()
52
53    # [refactor-todo]: requires "driver" for GPIO and RTC  (by sleep_gpio and sleep_modes)
54    list(APPEND priv_requires driver esp_timer)
55
56    if(CONFIG_IDF_TARGET_ESP32 OR CONFIG_IDF_TARGET_ESP32S2)
57        list(APPEND srcs "rtc_wdt.c")
58    endif()
59
60    if(CONFIG_SOC_GDMA_SUPPORTED)
61        list(APPEND srcs "dma/gdma.c" "dma/async_memcpy_impl_gdma.c")
62        if(CONFIG_SOC_PAU_SUPPORTED)
63            list(APPEND srcs "dma/gdma_sleep_retention.c")
64        endif()
65    endif()
66
67    if(CONFIG_SOC_CP_DMA_SUPPORTED)
68        list(APPEND srcs "dma/async_memcpy_impl_cp_dma.c")
69    endif()
70
71    if(CONFIG_SOC_ASYNC_MEMCPY_SUPPORTED)
72        list(APPEND srcs "dma/esp_async_memcpy.c")
73    endif()
74
75    if(CONFIG_SOC_GDMA_SUPPORT_ETM)
76        list(APPEND srcs "dma/gdma_etm.c")
77    endif()
78
79    if(CONFIG_SOC_SYSTIMER_SUPPORTED)
80        list(APPEND srcs "port/${target}/systimer.c")
81    endif()
82
83    if(CONFIG_SOC_HMAC_SUPPORTED)
84        list(APPEND srcs "esp_hmac.c")
85    endif()
86
87    if(CONFIG_SOC_ETM_SUPPORTED)
88        list(APPEND srcs "esp_etm.c")
89    endif()
90
91    if(CONFIG_SOC_CRYPTO_DPA_PROTECTION_SUPPORTED)
92        list(APPEND srcs "esp_dpa_protection.c")
93    endif()
94
95    if(CONFIG_SOC_DIG_SIGN_SUPPORTED)
96        list(APPEND srcs "esp_ds.c")
97    endif()
98
99    if(CONFIG_SOC_PAU_SUPPORTED)
100        list(APPEND srcs "port/pau_regdma.c"
101                         "port/regdma_link.c")
102    endif()
103
104    if(CONFIG_SOC_PM_CPU_RETENTION_BY_SW)
105        list(APPEND srcs "sleep_cpu_asm.S")
106        set_property(TARGET ${COMPONENT_LIB}
107                    APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u rv_core_critical_regs_save")
108        set_property(TARGET ${COMPONENT_LIB}
109                    APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u rv_core_critical_regs_restore")
110    endif()
111
112    if(CONFIG_SOC_MODEM_CLOCK_IS_INDEPENDENT)
113        list(APPEND srcs "modem_clock.c")
114    endif()
115
116    if(CONFIG_SOC_MEMSPI_SRC_FREQ_120M)
117        list(APPEND srcs "mspi_timing_tuning.c" "port/${target}/mspi_timing_config.c")
118    endif()
119
120    if(CONFIG_SOC_RTC_FAST_MEM_SUPPORTED)
121        list(APPEND srcs "sleep_wake_stub.c")
122    endif()
123else()
124    # Requires "_esp_error_check_failed()" function
125    list(APPEND priv_requires "esp_system")
126endif()
127
128idf_component_register(SRCS ${srcs}
129                       INCLUDE_DIRS include include/soc include/soc/${target}
130                       PRIV_INCLUDE_DIRS port/include include/esp_private
131                       REQUIRES ${requires}
132                       PRIV_REQUIRES "${priv_requires}"
133                       LDFRAGMENTS linker.lf)
134
135idf_build_get_property(target IDF_TARGET)
136add_subdirectory(port/${target})
137
138if(NOT BOOTLOADER_BUILD)
139    if(CONFIG_SPIRAM)
140        idf_component_optional_requires(PRIVATE esp_psram)
141    endif()
142    if(CONFIG_SOC_CRYPTO_DPA_PROTECTION_SUPPORTED)
143        target_link_libraries(${COMPONENT_LIB} PRIVATE "-u esp_crypto_dpa_prot_include_impl")
144    endif()
145endif()
146
147target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
148