From db2435fd14e266b7997580a9342247e10175c752 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Fri, 23 Feb 2024 16:50:31 +0800 Subject: [PATCH] feat(soc_cap_kconfig): support to search recursively --- .../esp_rom/esp32c5/Kconfig.soc_caps.in | 9 +- components/esp_rom/esp32c5/esp_rom_caps.h | 17 + .../esp32c5/mp/esp32c5/Kconfig.soc_caps.in | 4 + .../esp_rom/esp32c5/mp/esp32c5/esp_rom_caps.h | 7 + .../beta3/include/soc/Kconfig.soc_caps.in | 50 +- .../esp32c5/include/soc/Kconfig.soc_caps.in | 461 +----------------- components/soc/esp32c5/include/soc/soc_caps.h | 17 + .../mp/include/soc/Kconfig.soc_caps.in | 4 + .../soc/esp32c5/mp/include/soc/soc_caps.h | 5 + components/soc/esp32c5/mp/soc/.gitkeep | 0 .../gen_soc_caps_kconfig.py | 43 ++ 11 files changed, 156 insertions(+), 461 deletions(-) create mode 100644 components/esp_rom/esp32c5/esp_rom_caps.h create mode 100644 components/esp_rom/esp32c5/mp/esp32c5/Kconfig.soc_caps.in create mode 100644 components/esp_rom/esp32c5/mp/esp32c5/esp_rom_caps.h create mode 100644 components/soc/esp32c5/include/soc/soc_caps.h create mode 100644 components/soc/esp32c5/mp/include/soc/Kconfig.soc_caps.in create mode 100644 components/soc/esp32c5/mp/include/soc/soc_caps.h delete mode 100644 components/soc/esp32c5/mp/soc/.gitkeep diff --git a/components/esp_rom/esp32c5/Kconfig.soc_caps.in b/components/esp_rom/esp32c5/Kconfig.soc_caps.in index 42f7cf5650..20c519bbcb 100644 --- a/components/esp_rom/esp32c5/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32c5/Kconfig.soc_caps.in @@ -1,7 +1,12 @@ +##################################################### +# This file is auto-generated from SoC caps +# using gen_soc_caps_kconfig.py, do not edit manually +##################################################### + if IDF_TARGET_ESP32C5_BETA3_VERSION - orsource "./beta3/esp32c5/Kconfig.soc_caps.in" + source "$IDF_PATH/components/esp_rom/esp32c5/beta3/esp32c5/Kconfig.soc_caps.in" endif if IDF_TARGET_ESP32C5_MP_VERSION - orsource "./mp/esp32c5/Kconfig.soc_caps.in" + source "$IDF_PATH/components/esp_rom/esp32c5/mp/esp32c5/Kconfig.soc_caps.in" endif diff --git a/components/esp_rom/esp32c5/esp_rom_caps.h b/components/esp_rom/esp32c5/esp_rom_caps.h new file mode 100644 index 0000000000..0cbcedf2e4 --- /dev/null +++ b/components/esp_rom/esp32c5/esp_rom_caps.h @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "sdkconfig.h" + +// TODO: IDF-9197 This file is created to glob the soc_caps correctly in esp-docs + +#if CONFIG_IDF_TARGET_ESP32C5_BETA3_VERSION +#include "beta3/esp32c5/esp_rom_caps.h" // recursive, condition: IDF_TARGET_ESP32C5_BETA3_VERSION +#elif CONFIG_IDF_TARGET_ESP32C5_MP_VERSION +#include "mp/esp32c5/esp_rom_caps.h" // recursive, condition: IDF_TARGET_ESP32C5_MP_VERSION +#endif diff --git a/components/esp_rom/esp32c5/mp/esp32c5/Kconfig.soc_caps.in b/components/esp_rom/esp32c5/mp/esp32c5/Kconfig.soc_caps.in new file mode 100644 index 0000000000..51b3aa0d10 --- /dev/null +++ b/components/esp_rom/esp32c5/mp/esp32c5/Kconfig.soc_caps.in @@ -0,0 +1,4 @@ +##################################################### +# This file is auto-generated from SoC caps +# using gen_soc_caps_kconfig.py, do not edit manually +##################################################### diff --git a/components/esp_rom/esp32c5/mp/esp32c5/esp_rom_caps.h b/components/esp_rom/esp32c5/mp/esp32c5/esp_rom_caps.h new file mode 100644 index 0000000000..dd3f635e54 --- /dev/null +++ b/components/esp_rom/esp32c5/mp/esp32c5/esp_rom_caps.h @@ -0,0 +1,7 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once diff --git a/components/soc/esp32c5/beta3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/beta3/include/soc/Kconfig.soc_caps.in index 7d59c51278..ce60b9616a 100644 --- a/components/soc/esp32c5/beta3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/beta3/include/soc/Kconfig.soc_caps.in @@ -31,6 +31,14 @@ config SOC_SYSTIMER_SUPPORTED bool default y +config SOC_ECC_SUPPORTED + bool + default y + +config SOC_ECC_EXTENDED_MODES_SUPPORTED + bool + default y + config SOC_FLASH_ENC_SUPPORTED bool default y @@ -107,17 +115,49 @@ config SOC_CPU_IDRAM_SPLIT_USING_PMP bool default y +config SOC_GPIO_PORT + int + default 1 + config SOC_GPIO_PIN_COUNT int - default 31 + default 27 + +config SOC_GPIO_SUPPORT_PIN_HYS_FILTER + bool + default y + +config SOC_GPIO_ETM_EVENTS_PER_GROUP + int + default 8 + +config SOC_GPIO_ETM_TASKS_PER_GROUP + int + default 8 + +config SOC_GPIO_SUPPORT_RTC_INDEPENDENT + bool + default y config SOC_GPIO_IN_RANGE_MAX int - default 30 + default 26 config SOC_GPIO_OUT_RANGE_MAX int - default 30 + default 26 + +config SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK + int + default 0 + +config SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK + hex + default 0x0000000007FFFF00 + +config SOC_GPIO_SUPPORT_FORCE_HOLD + bool + default y config SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP bool @@ -295,10 +335,6 @@ config SOC_PM_SUPPORT_VDDSDIO_PD bool default y -config SOC_PM_SUPPORT_TOP_PD - bool - default y - config SOC_PM_SUPPORT_HP_AON_PD bool default y diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index efbb51f916..e5e3b806d2 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -1,455 +1,12 @@ +##################################################### +# This file is auto-generated from SoC caps +# using gen_soc_caps_kconfig.py, do not edit manually +##################################################### + if IDF_TARGET_ESP32C5_BETA3_VERSION - orsource "../../beta3/include/soc/Kconfig.soc_caps.in" + source "$IDF_PATH/components/soc/esp32c5/include/soc/../../beta3/include/soc/Kconfig.soc_caps.in" endif -config SOC_UART_SUPPORTED - bool - default y - -config SOC_GDMA_SUPPORTED - bool - default y - -config SOC_AHB_GDMA_SUPPORTED - bool - default y - -config SOC_GPTIMER_SUPPORTED - bool - default y - -config SOC_ASYNC_MEMCPY_SUPPORTED - bool - default y - -config SOC_EFUSE_KEY_PURPOSE_FIELD - bool - default y - -config SOC_EFUSE_SUPPORTED - bool - default y - -config SOC_RTC_FAST_MEM_SUPPORTED - bool - default y - -config SOC_RTC_MEM_SUPPORTED - bool - default y - -config SOC_I2C_SUPPORTED - bool - default y - -config SOC_SYSTIMER_SUPPORTED - bool - default y - -config SOC_ECC_SUPPORTED - bool - default y - -config SOC_ECC_EXTENDED_MODES_SUPPORTED - bool - default y - -config SOC_FLASH_ENC_SUPPORTED - bool - default y - -config SOC_LP_PERIPHERALS_SUPPORTED - bool - default y - -config SOC_SPI_FLASH_SUPPORTED - bool - default y - -config SOC_XTAL_SUPPORT_40M - bool - default y - -config SOC_XTAL_SUPPORT_48M - bool - default y - -config SOC_ADC_PERIPH_NUM - int - default 1 - -config SOC_ADC_MAX_CHANNEL_NUM - int - default 7 - -config SOC_SHARED_IDCACHE_SUPPORTED - bool - default y - -config SOC_CACHE_FREEZE_SUPPORTED - bool - default y - -config SOC_CPU_CORES_NUM - int - default 1 - -config SOC_CPU_INTR_NUM - int - default 32 - -config SOC_CPU_HAS_FLEXIBLE_INTC - bool - default y - -config SOC_INT_CLIC_SUPPORTED - bool - default y - -config SOC_INT_HW_NESTED_SUPPORTED - bool - default y - -config SOC_BRANCH_PREDICTOR_SUPPORTED - bool - default y - -config SOC_CPU_BREAKPOINTS_NUM - int - default 4 - -config SOC_CPU_WATCHPOINTS_NUM - int - default 4 - -config SOC_CPU_WATCHPOINT_MAX_REGION_SIZE - hex - default 0x100 - -config SOC_CPU_HAS_PMA - bool - default y - -config SOC_CPU_IDRAM_SPLIT_USING_PMP - bool - default y - -config SOC_AHB_GDMA_VERSION - int - default 1 - -config SOC_GDMA_NUM_GROUPS_MAX - int - default 1 - -config SOC_GDMA_PAIRS_PER_GROUP_MAX - int - default 3 - -config SOC_GPIO_PORT - int - default 1 - -config SOC_GPIO_PIN_COUNT - int - default 27 - -config SOC_GPIO_SUPPORT_PIN_HYS_FILTER - bool - default y - -config SOC_GPIO_ETM_EVENTS_PER_GROUP - int - default 8 - -config SOC_GPIO_ETM_TASKS_PER_GROUP - int - default 8 - -config SOC_GPIO_SUPPORT_RTC_INDEPENDENT - bool - default y - -config SOC_GPIO_IN_RANGE_MAX - int - default 26 - -config SOC_GPIO_OUT_RANGE_MAX - int - default 26 - -config SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK - int - default 0 - -config SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK - hex - default 0x0000000007FFFF00 - -config SOC_GPIO_SUPPORT_FORCE_HOLD - bool - default y - -config SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP - bool - default y - -config SOC_RTCIO_PIN_COUNT - bool - default n - -config SOC_I2C_NUM - int - default 1 - -config SOC_I2C_FIFO_LEN - int - default 32 - -config SOC_I2C_CMD_REG_NUM - int - default 8 - -config SOC_I2C_SUPPORT_SLAVE - bool - default y - -config SOC_I2C_SUPPORT_HW_FSM_RST - bool - default y - -config SOC_I2C_SUPPORT_HW_CLR_BUS - bool - default y - -config SOC_I2C_SUPPORT_XTAL - bool - default y - -config SOC_I2C_SUPPORT_10BIT_ADDR - bool - default y - -config SOC_I2C_SLAVE_SUPPORT_BROADCAST - bool - default y - -config SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE - bool - default y - -config SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS - bool - default y - -config SOC_LEDC_SUPPORT_PLL_DIV_CLOCK - bool - default y - -config SOC_LEDC_SUPPORT_XTAL_CLOCK - bool - default y - -config SOC_LEDC_CHANNEL_NUM - int - default 6 - -config SOC_MMU_PERIPH_NUM - int - default 1 - -config SOC_MMU_LINEAR_ADDRESS_REGION_NUM - int - default 1 - -config SOC_MMU_DI_VADDR_SHARED - bool - default y - -config SOC_RSA_MAX_BIT_LEN - int - default 3072 - -config SOC_SPI_PERIPH_NUM - int - default 2 - -config SOC_SPI_MAX_CS_NUM - int - default 6 - -config SOC_MEMSPI_SRC_FREQ_80M_SUPPORTED - bool - default y - -config SOC_MEMSPI_SRC_FREQ_40M_SUPPORTED - bool - default y - -config SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED - bool - default y - -config SOC_SYSTIMER_COUNTER_NUM - int - default 2 - -config SOC_SYSTIMER_ALARM_NUM - int - default 3 - -config SOC_SYSTIMER_BIT_WIDTH_LO - int - default 32 - -config SOC_SYSTIMER_BIT_WIDTH_HI - int - default 20 - -config SOC_SYSTIMER_FIXED_DIVIDER - bool - default y - -config SOC_SYSTIMER_SUPPORT_RC_FAST - bool - default y - -config SOC_SYSTIMER_INT_LEVEL - bool - default y - -config SOC_SYSTIMER_ALARM_MISS_COMPENSATE - bool - default y - -config SOC_TIMER_GROUPS - int - default 2 - -config SOC_TIMER_GROUP_TIMERS_PER_GROUP - int - default 1 - -config SOC_TIMER_GROUP_COUNTER_BIT_WIDTH - int - default 54 - -config SOC_TIMER_GROUP_SUPPORT_XTAL - bool - default y - -config SOC_TIMER_GROUP_TOTAL_TIMERS - int - default 2 - -config SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS - int - default 3 - -config SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX - int - default 64 - -config SOC_FLASH_ENCRYPTION_XTS_AES - bool - default y - -config SOC_FLASH_ENCRYPTION_XTS_AES_128 - bool - default y - -config SOC_UART_NUM - int - default 3 - -config SOC_UART_HP_NUM - int - default 2 - -config SOC_UART_LP_NUM - int - default 1 - -config SOC_UART_FIFO_LEN - int - default 128 - -config SOC_LP_UART_FIFO_LEN - int - default 16 - -config SOC_UART_BITRATE_MAX - int - default 5000000 - -config SOC_UART_SUPPORT_PLL_F80M_CLK - bool - default y - -config SOC_UART_SUPPORT_XTAL_CLK - bool - default y - -config SOC_UART_SUPPORT_WAKEUP_INT - bool - default y - -config SOC_UART_SUPPORT_FSM_TX_WAIT_SEND - bool - default y - -config SOC_PM_SUPPORT_CPU_PD - bool - default y - -config SOC_PM_SUPPORT_MODEM_PD - bool - default y - -config SOC_PM_SUPPORT_XTAL32K_PD - bool - default y - -config SOC_PM_SUPPORT_RC32K_PD - bool - default y - -config SOC_PM_SUPPORT_RC_FAST_PD - bool - default y - -config SOC_PM_SUPPORT_VDDSDIO_PD - bool - default y - -config SOC_PM_SUPPORT_HP_AON_PD - bool - default y - -config SOC_PM_SUPPORT_RTC_PERIPH_PD - bool - default y - -config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION - bool - default y - -config SOC_MODEM_CLOCK_IS_INDEPENDENT - bool - default y - -config SOC_CLK_XTAL32K_SUPPORTED - bool - default y - -config SOC_CLK_OSC_SLOW_SUPPORTED - bool - default y - -config SOC_CLK_RC32K_SUPPORTED - bool - default y - -config SOC_RCC_IS_INDEPENDENT - bool - default y +if IDF_TARGET_ESP32C5_MP_VERSION + source "$IDF_PATH/components/soc/esp32c5/include/soc/../../mp/include/soc/Kconfig.soc_caps.in" +endif diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h new file mode 100644 index 0000000000..92ea81c451 --- /dev/null +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "sdkconfig.h" + +// TODO: IDF-9197 This file is created to glob the soc_caps correctly in esp-docs + +#if CONFIG_IDF_TARGET_ESP32C5_BETA3_VERSION +#include "../../beta3/include/soc/soc_caps.h" // recursive, condition: IDF_TARGET_ESP32C5_BETA3_VERSION +#elif CONFIG_IDF_TARGET_ESP32C5_MP_VERSION +#include "../../mp/include/soc/soc_caps.h" // recursive, condition: IDF_TARGET_ESP32C5_MP_VERSION +#endif diff --git a/components/soc/esp32c5/mp/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/mp/include/soc/Kconfig.soc_caps.in new file mode 100644 index 0000000000..51b3aa0d10 --- /dev/null +++ b/components/soc/esp32c5/mp/include/soc/Kconfig.soc_caps.in @@ -0,0 +1,4 @@ +##################################################### +# This file is auto-generated from SoC caps +# using gen_soc_caps_kconfig.py, do not edit manually +##################################################### diff --git a/components/soc/esp32c5/mp/include/soc/soc_caps.h b/components/soc/esp32c5/mp/include/soc/soc_caps.h new file mode 100644 index 0000000000..972389e04d --- /dev/null +++ b/components/soc/esp32c5/mp/include/soc/soc_caps.h @@ -0,0 +1,5 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/soc/esp32c5/mp/soc/.gitkeep b/components/soc/esp32c5/mp/soc/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tools/gen_soc_caps_kconfig/gen_soc_caps_kconfig.py b/tools/gen_soc_caps_kconfig/gen_soc_caps_kconfig.py index 3ba6608652..293a25c133 100755 --- a/tools/gen_soc_caps_kconfig/gen_soc_caps_kconfig.py +++ b/tools/gen_soc_caps_kconfig/gen_soc_caps_kconfig.py @@ -28,6 +28,8 @@ from pyparsing import OneOrMore from pyparsing import Optional from pyparsing import ParserElement from pyparsing import QuotedString +from pyparsing import restOfLine +from pyparsing import Suppress from pyparsing import Word pyparsing.usePackrat = True @@ -52,6 +54,12 @@ class KconfigWriter(): $entry_type default $value ''')) + KCONFIG_CONDITION_SOURCE_TEMPLATE = Template( + inspect.cleandoc(''' + if $condition + source "$source_path" + endif + ''')) def __init__(self): # type: () -> None self.entries = set('') @@ -77,6 +85,14 @@ class KconfigWriter(): entry = self.KCONFIG_ENTRY_TEMPLATE.substitute(name=name, entry_type=entry_type, value=value) self.kconfig_text.write(entry) + def add_source(self, source_path, condition): # type: (str, str) -> None + self.kconfig_text.write('\n\n') + if condition: + source = self.KCONFIG_CONDITION_SOURCE_TEMPLATE.substitute(source_path=source_path, condition=condition) + self.kconfig_text.write(source) + else: + self.kconfig_text.write('source "' + source_path + '"') + def update_file(self, kconfig_path, always_write): # type: (Path, bool) -> bool try: @@ -105,6 +121,22 @@ class KconfigWriter(): return file_needs_update +def parse_include(inc_line): # type: (str) -> typing.Any[typing.Type[ParserElement]] + # Comment with recursive pattern + recursive_deli = OneOrMore(Group(Literal(' ') | Literal(',') | Literal('.'))) + recursive = CaselessLiteral('// recursive')('recursive') + Optional(recursive_deli) + + # Comment with condition pattern + condition_deli = OneOrMore(Group(Literal(' ') | Literal(':'))) + condition = CaselessLiteral('condition') + Optional(condition_deli) + restOfLine('condition') + + # Parse the include line + # e.g. #include "../../beta3/include/soc/soc_caps.h" // recursive, condition: IDF_TARGET_ESP32C5_VERSION_BETA3 + expr = Suppress('#include') + QuotedString('"')('inc_path') + recursive + Optional(condition) + res = expr.parseString(inc_line) + return res + + def parse_define(define_line): # type: (str) -> typing.Any[typing.Type[ParserElement]] # Group for parsing literal suffix of a numbers, e.g. 100UL @@ -144,6 +176,17 @@ def generate_defines(soc_caps_dir, filename, always_write): # type: (Path, str, writer = KconfigWriter() for line in defines: + try: + inc = parse_include(line) + if 'inc_path' in inc and 'recursive' in inc and inc['inc_path'][-6:] == 'caps.h': + source_path = path.join('$IDF_PATH', str(soc_caps_dir), path.dirname(inc['inc_path']), 'Kconfig.soc_caps.in') + condition = inc['condition'].strip(' ') if 'condition' in inc else '' + writer.add_source(source_path, condition) + sub_soc_cap_dir = soc_caps_dir.joinpath(str(inc['inc_path'])).parent + generate_defines(sub_soc_cap_dir, filename, always_write) + continue + except pyparsing.ParseException: + pass try: res = parse_define(line)