Skip to content

Commit 9043e65

Browse files
soburikartben
authored andcommitted
drivers: watchdog: rpi_pico: Add support for RP2350
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>
1 parent 8d39008 commit 9043e65

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/watchdog/wdt_rpi_pico.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define DT_DRV_COMPAT raspberrypi_pico_watchdog
88

99
#include <hardware/watchdog.h>
10+
#include <hardware/ticks.h>
1011
#include <hardware/structs/psm.h>
1112
#include <zephyr/drivers/clock_control.h>
1213
#include <zephyr/drivers/watchdog.h>
@@ -15,9 +16,13 @@
1516
#include <zephyr/logging/log.h>
1617
LOG_MODULE_REGISTER(wdt_rpi_pico, CONFIG_WDT_LOG_LEVEL);
1718

19+
#ifdef CONFIG_SOC_RP2040
1820
/* Maximum watchdog time is halved due to errata RP2040-E1 */
19-
#define RPI_PICO_MAX_WDT_TIME (0xffffff / 2)
2021
#define RPI_PICO_WDT_TIME_MULTIPLICATION_FACTOR 2
22+
#else
23+
#define RPI_PICO_WDT_TIME_MULTIPLICATION_FACTOR 1
24+
#endif
25+
#define RPI_PICO_MAX_WDT_TIME (0xffffff / RPI_PICO_WDT_TIME_MULTIPLICATION_FACTOR)
2126

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

97+
#ifdef CONFIG_SOC_RP2040
9298
watchdog_hw->tick = (ref_clk / RPI_PICO_CLK_REF_FREQ_WDT_TICK_DIVISOR) |
9399
WATCHDOG_TICK_ENABLE_BITS;
100+
#else
101+
ticks_hw->ticks[TICK_WATCHDOG].cycles = ref_clk / RPI_PICO_CLK_REF_FREQ_WDT_TICK_DIVISOR;
102+
ticks_hw->ticks[TICK_WATCHDOG].ctrl = TICKS_WATCHDOG_CTRL_ENABLE_BITS;
103+
#endif
94104

95105
return 0;
96106
}

0 commit comments

Comments
 (0)