Skip to content

Commit 8d39008

Browse files
ajf58kartben
authored andcommitted
drivers: clock_control: rpi_pico: Start tick generators for timers
Unlike the RP2040, the RP2350 has multiple tick generators that need to be started. Start TIMER0 and TIMER1 tick generators during clock_control_init. Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
1 parent 1d3f5ac commit 8d39008

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

drivers/clock_control/clock_control_rpi_pico.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <hardware/pll.h>
2323
#include <hardware/watchdog.h>
2424
#include <hardware/resets.h>
25+
#include <hardware/ticks.h>
2526

2627
/* Undefine to prevent conflicts with header definitions */
2728
#undef pll_sys
@@ -646,6 +647,7 @@ void rpi_pico_clkid_tuple_reorder_by_dependencies(struct rpi_pico_clkid_tuple *t
646647

647648
static int clock_control_rpi_pico_init(const struct device *dev)
648649
{
650+
const uint32_t cycles_per_tick = CLOCK_FREQ_xosc / 1000000;
649651
const struct clock_control_rpi_pico_config *config = dev->config;
650652
struct clock_control_rpi_pico_data *data = dev->data;
651653
clocks_hw_t *clocks_regs = config->clocks_regs;
@@ -674,7 +676,11 @@ static int clock_control_rpi_pico_init(const struct device *dev)
674676
RESETS_RESET_USBCTRL_BITS));
675677

676678
/* Start tick in watchdog */
677-
watchdog_start_tick(CLOCK_FREQ_xosc / 1000000);
679+
watchdog_start_tick(cycles_per_tick);
680+
#if defined(CONFIG_SOC_SERIES_RP2350)
681+
tick_start(TICK_TIMER0, cycles_per_tick);
682+
tick_start(TICK_TIMER1, cycles_per_tick);
683+
#endif
678684

679685
clocks_regs->resus.ctrl = 0;
680686

modules/hal_rpi_pico/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ if(CONFIG_HAS_RPI_PICO)
6262
${rp2_common_dir}/hardware_xosc/xosc.c
6363
${rp2_common_dir}/hardware_watchdog/watchdog.c
6464
${rp2_common_dir}/hardware_sync_spin_lock/sync_spin_lock.c
65+
${rp2_common_dir}/hardware_ticks/ticks.c
6566
${rp2_common_dir}/pico_bootrom/bootrom.c
6667
${rp2xxx_dir}/pico_platform/platform.c
6768
)

0 commit comments

Comments
 (0)