From 909f7922d64faeecda03aa3a2ea1ecad24d9501a Mon Sep 17 00:00:00 2001 From: Raffael Rostagno Date: Wed, 3 Apr 2024 11:38:13 -0300 Subject: [PATCH] drivers: watchdog: Added support to C6 Added support to watchdog timer to ESP32C6 Signed-off-by: Raffael Rostagno --- .../esp32c6_devkitc/esp32c6_devkitc.dts | 5 +++++ drivers/watchdog/wdt_esp32.c | 12 ++++++++---- .../espressif/esp32c6/esp32c6_common.dtsi | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/boards/espressif/esp32c6_devkitc/esp32c6_devkitc.dts b/boards/espressif/esp32c6_devkitc/esp32c6_devkitc.dts index 88386550787..af3c57f11f9 100644 --- a/boards/espressif/esp32c6_devkitc/esp32c6_devkitc.dts +++ b/boards/espressif/esp32c6_devkitc/esp32c6_devkitc.dts @@ -23,6 +23,7 @@ aliases { sw0 = &user_button1; + watchdog0 = &wdt0; }; gpio_keys { @@ -49,6 +50,10 @@ status = "okay"; }; +&wdt0 { + status = "okay"; +}; + &flash0 { status = "okay"; partitions { diff --git a/drivers/watchdog/wdt_esp32.c b/drivers/watchdog/wdt_esp32.c index 460f130c1b5..f5ef51fad02 100644 --- a/drivers/watchdog/wdt_esp32.c +++ b/drivers/watchdog/wdt_esp32.c @@ -7,7 +7,11 @@ #define DT_DRV_COMPAT espressif_esp32_watchdog /* Include esp-idf headers first to avoid redefining BIT() macro */ +#if defined(CONFIG_SOC_SERIES_ESP32C6) +#include +#else #include +#endif #include #include #include @@ -15,17 +19,17 @@ #include #include #include -#ifndef CONFIG_SOC_SERIES_ESP32C3 -#include -#else +#if defined(CONFIG_SOC_SERIES_ESP32C3) || defined(CONFIG_SOC_SERIES_ESP32C6) #include +#else +#include #endif #include #include LOG_MODULE_REGISTER(wdt_esp32, CONFIG_WDT_LOG_LEVEL); -#ifdef CONFIG_SOC_SERIES_ESP32C3 +#if defined(CONFIG_SOC_SERIES_ESP32C3) || defined(CONFIG_SOC_SERIES_ESP32C6) #define ISR_HANDLER isr_handler_t #else #define ISR_HANDLER intr_handler_t diff --git a/dts/riscv/espressif/esp32c6/esp32c6_common.dtsi b/dts/riscv/espressif/esp32c6/esp32c6_common.dtsi index 175921df6bc..463e2cd93df 100644 --- a/dts/riscv/espressif/esp32c6/esp32c6_common.dtsi +++ b/dts/riscv/espressif/esp32c6/esp32c6_common.dtsi @@ -78,6 +78,24 @@ }; }; + wdt0: watchdog@6001f048 { + compatible = "espressif,esp32-watchdog"; + reg = <0x6001f048 0x20>; + interrupts = ; + interrupt-parent = <&intc>; + clocks = <&rtc ESP32_TIMG0_MODULE>; + status = "disabled"; + }; + + wdt1: watchdog@60020048 { + compatible = "espressif,esp32-watchdog"; + reg = <0x60020048 0x20>; + interrupts = ; + interrupt-parent = <&intc>; + clocks = <&rtc ESP32_TIMG1_MODULE>; + status = "disabled"; + }; + flash: flash-controller@60002000 { compatible = "espressif,esp32-flash-controller"; reg = <0x60002000 0x1000>;