esp32[c3|c6|h2]: Add MWDT1 support

This commit is contained in:
Eren Terzioglu 2024-05-21 16:03:57 +03:00 committed by Xiang Xiao
parent aa0bb55529
commit ea9eea4096
11 changed files with 105 additions and 28 deletions

View File

@ -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"

View File

@ -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:
{

View File

@ -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) */
};
/****************************************************************************

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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);