Skip to content

Commit

Permalink
drivers: watchdog: rpi_pico: Add support for RP2350
Browse files Browse the repository at this point in the history
The watchdog register configuration of RP2350 differs from that
of RP2040, so we make fit that.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
  • Loading branch information
soburi authored and kartben committed Dec 23, 2024
1 parent 8d39008 commit 9043e65
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/watchdog/wdt_rpi_pico.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define DT_DRV_COMPAT raspberrypi_pico_watchdog

#include <hardware/watchdog.h>
#include <hardware/ticks.h>
#include <hardware/structs/psm.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/drivers/watchdog.h>
Expand All @@ -15,9 +16,13 @@
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(wdt_rpi_pico, CONFIG_WDT_LOG_LEVEL);

#ifdef CONFIG_SOC_RP2040
/* Maximum watchdog time is halved due to errata RP2040-E1 */
#define RPI_PICO_MAX_WDT_TIME (0xffffff / 2)
#define RPI_PICO_WDT_TIME_MULTIPLICATION_FACTOR 2
#else
#define RPI_PICO_WDT_TIME_MULTIPLICATION_FACTOR 1
#endif
#define RPI_PICO_MAX_WDT_TIME (0xffffff / RPI_PICO_WDT_TIME_MULTIPLICATION_FACTOR)

/* Watchdog requires a 1MHz clock source, divided from the crystal oscillator */
#define RPI_PICO_CLK_REF_FREQ_WDT_TICK_DIVISOR 1000000
Expand Down Expand Up @@ -89,8 +94,13 @@ static int wdt_rpi_pico_setup(const struct device *dev, uint8_t options)
return err;
}

#ifdef CONFIG_SOC_RP2040
watchdog_hw->tick = (ref_clk / RPI_PICO_CLK_REF_FREQ_WDT_TICK_DIVISOR) |
WATCHDOG_TICK_ENABLE_BITS;
#else
ticks_hw->ticks[TICK_WATCHDOG].cycles = ref_clk / RPI_PICO_CLK_REF_FREQ_WDT_TICK_DIVISOR;
ticks_hw->ticks[TICK_WATCHDOG].ctrl = TICKS_WATCHDOG_CTRL_ENABLE_BITS;
#endif

return 0;
}
Expand Down

0 comments on commit 9043e65

Please sign in to comment.