diff --git a/arch/risc-v/src/common/espressif/Kconfig b/arch/risc-v/src/common/espressif/Kconfig index ee516053ef..4db4627d62 100644 --- a/arch/risc-v/src/common/espressif/Kconfig +++ b/arch/risc-v/src/common/espressif/Kconfig @@ -333,12 +333,21 @@ config ESPRESSIF_WDT default n select WATCHDOG -config ESPRESSIF_MWDT - bool "Main System Watchdog Timer" +config ESPRESSIF_MWDT0 + bool "Main System Watchdog Timer (Group 0)" default n select ESPRESSIF_WDT ---help--- - Includes MWDT. + Includes MWDT0. This watchdog timer is part of the Group 0 + timer submodule. + +config ESPRESSIF_MWDT1 + bool "Main System Watchdog Timer (Group 1)" + default n + select ESPRESSIF_WDT + ---help--- + Includes MWDT1. This watchdog timer is part of the Group 1 + timer submodule. config ESPRESSIF_RWDT bool "RTC Watchdog Timer" diff --git a/arch/risc-v/src/common/espressif/esp_wdt.c b/arch/risc-v/src/common/espressif/esp_wdt.c index dcf4492544..f059fcb370 100644 --- a/arch/risc-v/src/common/espressif/esp_wdt.c +++ b/arch/risc-v/src/common/espressif/esp_wdt.c @@ -150,21 +150,39 @@ static const struct watchdog_ops_s g_esp_wdg_ops = .ioctl = NULL }; -#ifdef CONFIG_ESPRESSIF_MWDT +#ifdef CONFIG_ESPRESSIF_MWDT0 /* Watchdog HAL context */ -static wdt_hal_context_t mwdt_hal_ctx; +static wdt_hal_context_t mwdt0_hal_ctx; /* MWDT0 lower-half */ -static struct esp_wdt_lowerhalf_s g_esp_mwdt_lowerhalf = +static struct esp_wdt_lowerhalf_s g_esp_mwdt0_lowerhalf = { .ops = &g_esp_wdg_ops, .timeout = MWDT_MAX_TIMEOUT_MS, .periph = TG0_WDT_LEVEL_INTR_SOURCE, .peripheral = TIMER, .irq = ESP_IRQ_TG0_WDT_LEVEL, - .ctx = &mwdt_hal_ctx + .ctx = &mwdt0_hal_ctx +}; +#endif + +#ifdef CONFIG_ESPRESSIF_MWDT1 +/* Watchdog HAL context */ + +static wdt_hal_context_t mwdt1_hal_ctx; + +/* MWDT1 lower-half */ + +static struct esp_wdt_lowerhalf_s g_esp_mwdt1_lowerhalf = +{ + .ops = &g_esp_wdg_ops, + .timeout = MWDT_MAX_TIMEOUT_MS, + .periph = TG1_WDT_LEVEL_INTR_SOURCE, + .peripheral = TIMER, + .irq = ESP_IRQ_TG1_WDT_LEVEL, + .ctx = &mwdt1_hal_ctx }; #endif @@ -668,10 +686,10 @@ int esp_wdt_initialize(const char *devpath, enum esp_wdt_inst_e wdt_id) switch (wdt_id) { -#ifdef CONFIG_ESPRESSIF_MWDT - case ESP_WDT_MWDT: +#ifdef CONFIG_ESPRESSIF_MWDT0 + case ESP_WDT_MWDT0: { - lower = &g_esp_mwdt_lowerhalf; + lower = &g_esp_mwdt0_lowerhalf; periph_module_enable(PERIPH_TIMG0_MODULE); wdt_hal_init(lower->ctx, WDT_MWDT0, MWDT_LL_DEFAULT_CLK_PRESCALER, true); @@ -681,6 +699,19 @@ int esp_wdt_initialize(const char *devpath, enum esp_wdt_inst_e wdt_id) #endif +#ifdef CONFIG_ESPRESSIF_MWDT1 + case ESP_WDT_MWDT1: + { + lower = &g_esp_mwdt1_lowerhalf; + periph_module_enable(PERIPH_TIMG1_MODULE); + wdt_hal_init(lower->ctx, WDT_MWDT1, + MWDT_LL_DEFAULT_CLK_PRESCALER, true); + + break; + } + +#endif + #ifdef CONFIG_ESPRESSIF_RWDT case ESP_WDT_RWDT: { diff --git a/arch/risc-v/src/common/espressif/esp_wdt.h b/arch/risc-v/src/common/espressif/esp_wdt.h index c58e291f7f..e3f904c202 100644 --- a/arch/risc-v/src/common/espressif/esp_wdt.h +++ b/arch/risc-v/src/common/espressif/esp_wdt.h @@ -35,8 +35,9 @@ enum esp_wdt_inst_e { - ESP_WDT_MWDT = 0, /* Main System Watchdog Timer (MWDT) of Timer Group 0 */ - ESP_WDT_RWDT /* RTC Watchdog Timer (RWDT) */ + ESP_WDT_MWDT0 = 0, /* Main System Watchdog Timer (MWDT) of Timer Group 0 */ + ESP_WDT_MWDT1, /* Main System Watchdog Timer (MWDT) of Timer Group 1 */ + ESP_WDT_RWDT /* RTC Watchdog Timer (RWDT) */ }; /**************************************************************************** diff --git a/boards/risc-v/esp32c3/esp32c3-generic/configs/watchdog/defconfig b/boards/risc-v/esp32c3/esp32c3-generic/configs/watchdog/defconfig index e2900f822d..7920e53754 100644 --- a/boards/risc-v/esp32c3/esp32c3-generic/configs/watchdog/defconfig +++ b/boards/risc-v/esp32c3/esp32c3-generic/configs/watchdog/defconfig @@ -19,7 +19,8 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_BOARD_LOOPSPERMSEC=15000 CONFIG_BUILTIN=y CONFIG_DEV_ZERO=y -CONFIG_ESPRESSIF_MWDT=y +CONFIG_ESPRESSIF_MWDT0=y +CONFIG_ESPRESSIF_MWDT1=y CONFIG_EXAMPLES_WATCHDOG=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=2048 diff --git a/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_bringup.c b/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_bringup.c index abff6563d6..1dd0f62e82 100644 --- a/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_bringup.c +++ b/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_bringup.c @@ -128,8 +128,16 @@ int esp_bringup(void) } #endif -#ifdef CONFIG_ESPRESSIF_MWDT - ret = esp_wdt_initialize("/dev/watchdog0", ESP_WDT_MWDT); +#ifdef CONFIG_ESPRESSIF_MWDT0 + ret = esp_wdt_initialize("/dev/watchdog0", ESP_WDT_MWDT0); + if (ret < 0) + { + _err("Failed to initialize WDT: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESPRESSIF_MWDT1 + ret = esp_wdt_initialize("/dev/watchdog1", ESP_WDT_MWDT1); if (ret < 0) { _err("Failed to initialize WDT: %d\n", ret); @@ -137,7 +145,7 @@ int esp_bringup(void) #endif #ifdef CONFIG_ESPRESSIF_RWDT - ret = esp_wdt_initialize("/dev/watchdog1", ESP_WDT_RWDT); + ret = esp_wdt_initialize("/dev/watchdog2", ESP_WDT_RWDT); if (ret < 0) { _err("Failed to initialize WDT: %d\n", ret); diff --git a/boards/risc-v/esp32c6/esp32c6-devkitc/configs/watchdog/defconfig b/boards/risc-v/esp32c6/esp32c6-devkitc/configs/watchdog/defconfig index 5f1ce9db53..e114433d41 100644 --- a/boards/risc-v/esp32c6/esp32c6-devkitc/configs/watchdog/defconfig +++ b/boards/risc-v/esp32c6/esp32c6-devkitc/configs/watchdog/defconfig @@ -21,7 +21,8 @@ CONFIG_BOARD_LOOPSPERMSEC=15000 CONFIG_BUILTIN=y CONFIG_DEV_ZERO=y CONFIG_ESPRESSIF_ESP32C6=y -CONFIG_ESPRESSIF_MWDT=y +CONFIG_ESPRESSIF_MWDT0=y +CONFIG_ESPRESSIF_MWDT1=y CONFIG_EXAMPLES_WATCHDOG=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=2048 diff --git a/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c b/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c index 46a6a628ba..f353dda0ff 100644 --- a/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c +++ b/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c @@ -128,8 +128,16 @@ int esp_bringup(void) } #endif -#ifdef CONFIG_ESPRESSIF_MWDT - ret = esp_wdt_initialize("/dev/watchdog0", ESP_WDT_MWDT); +#ifdef CONFIG_ESPRESSIF_MWDT0 + ret = esp_wdt_initialize("/dev/watchdog0", ESP_WDT_MWDT0); + if (ret < 0) + { + _err("Failed to initialize WDT: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESPRESSIF_MWDT1 + ret = esp_wdt_initialize("/dev/watchdog1", ESP_WDT_MWDT1); if (ret < 0) { _err("Failed to initialize WDT: %d\n", ret); @@ -137,7 +145,7 @@ int esp_bringup(void) #endif #ifdef CONFIG_ESPRESSIF_RWDT - ret = esp_wdt_initialize("/dev/watchdog1", ESP_WDT_RWDT); + ret = esp_wdt_initialize("/dev/watchdog2", ESP_WDT_RWDT); if (ret < 0) { _err("Failed to initialize WDT: %d\n", ret); diff --git a/boards/risc-v/esp32c6/esp32c6-devkitm/configs/watchdog/defconfig b/boards/risc-v/esp32c6/esp32c6-devkitm/configs/watchdog/defconfig index 7836f09f68..7ac5f1a14b 100644 --- a/boards/risc-v/esp32c6/esp32c6-devkitm/configs/watchdog/defconfig +++ b/boards/risc-v/esp32c6/esp32c6-devkitm/configs/watchdog/defconfig @@ -21,7 +21,8 @@ CONFIG_BOARD_LOOPSPERMSEC=15000 CONFIG_BUILTIN=y CONFIG_DEV_ZERO=y CONFIG_ESPRESSIF_ESP32C6=y -CONFIG_ESPRESSIF_MWDT=y +CONFIG_ESPRESSIF_MWDT0=y +CONFIG_ESPRESSIF_MWDT1=y CONFIG_EXAMPLES_WATCHDOG=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=2048 diff --git a/boards/risc-v/esp32c6/esp32c6-devkitm/src/esp32c6_bringup.c b/boards/risc-v/esp32c6/esp32c6-devkitm/src/esp32c6_bringup.c index 7d72fa2e8f..03737dfe44 100644 --- a/boards/risc-v/esp32c6/esp32c6-devkitm/src/esp32c6_bringup.c +++ b/boards/risc-v/esp32c6/esp32c6-devkitm/src/esp32c6_bringup.c @@ -128,8 +128,16 @@ int esp_bringup(void) } #endif -#ifdef CONFIG_ESPRESSIF_MWDT - ret = esp_wdt_initialize("/dev/watchdog0", ESP_WDT_MWDT); +#ifdef CONFIG_ESPRESSIF_MWDT0 + ret = esp_wdt_initialize("/dev/watchdog0", ESP_WDT_MWDT0); + if (ret < 0) + { + _err("Failed to initialize WDT: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESPRESSIF_MWDT1 + ret = esp_wdt_initialize("/dev/watchdog1", ESP_WDT_MWDT1); if (ret < 0) { _err("Failed to initialize WDT: %d\n", ret); @@ -137,7 +145,7 @@ int esp_bringup(void) #endif #ifdef CONFIG_ESPRESSIF_RWDT - ret = esp_wdt_initialize("/dev/watchdog1", ESP_WDT_RWDT); + ret = esp_wdt_initialize("/dev/watchdog2", ESP_WDT_RWDT); if (ret < 0) { _err("Failed to initialize WDT: %d\n", ret); diff --git a/boards/risc-v/esp32h2/esp32h2-devkit/configs/watchdog/defconfig b/boards/risc-v/esp32h2/esp32h2-devkit/configs/watchdog/defconfig index 4e52443411..f11fc17c17 100644 --- a/boards/risc-v/esp32h2/esp32h2-devkit/configs/watchdog/defconfig +++ b/boards/risc-v/esp32h2/esp32h2-devkit/configs/watchdog/defconfig @@ -20,7 +20,8 @@ CONFIG_BOARD_LOOPSPERMSEC=15000 CONFIG_BUILTIN=y CONFIG_DEV_ZERO=y CONFIG_ESPRESSIF_ESP32H2=y -CONFIG_ESPRESSIF_MWDT=y +CONFIG_ESPRESSIF_MWDT0=y +CONFIG_ESPRESSIF_MWDT1=y CONFIG_EXAMPLES_WATCHDOG=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=2048 diff --git a/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c b/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c index f9d652028e..481d6d1340 100644 --- a/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c +++ b/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c @@ -120,8 +120,16 @@ int esp_bringup(void) } #endif -#ifdef CONFIG_ESPRESSIF_MWDT - ret = esp_wdt_initialize("/dev/watchdog0", ESP_WDT_MWDT); +#ifdef CONFIG_ESPRESSIF_MWDT0 + ret = esp_wdt_initialize("/dev/watchdog0", ESP_WDT_MWDT0); + if (ret < 0) + { + _err("Failed to initialize WDT: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESPRESSIF_MWDT1 + ret = esp_wdt_initialize("/dev/watchdog1", ESP_WDT_MWDT1); if (ret < 0) { _err("Failed to initialize WDT: %d\n", ret); @@ -129,7 +137,7 @@ int esp_bringup(void) #endif #ifdef CONFIG_ESPRESSIF_RWDT - ret = esp_wdt_initialize("/dev/watchdog1", ESP_WDT_RWDT); + ret = esp_wdt_initialize("/dev/watchdog2", ESP_WDT_RWDT); if (ret < 0) { _err("Failed to initialize WDT: %d\n", ret);