Skip to content

Commit ab0fe98

Browse files
drivers: timer : fix rtmr timer.
RTMR clear the interrupt status bit in the init and isr function. Signed-off-by: Lin Yu-Cheng <lin_yu_cheng@realtek.com>
1 parent 29197ac commit ab0fe98

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/timer/realtek_rts5912_rtmr.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
4343
#define RTMR_ADJUST_CYCLES 7
4444

4545
static struct k_spinlock lock;
46-
static uint32_t accumulated_cycles;
47-
static uint32_t previous_cnt; /* Record the counter set into RTMR */
48-
static uint32_t last_announcement; /* Record the last tick announced to system */
46+
static uint32_t accumulated_cycles = 0;
47+
static uint32_t previous_cnt = 0; /* Record the counter set into RTMR */
48+
static uint32_t last_announcement = 0; /* Record the last tick announced to system */
4949

5050
static void rtmr_restart(uint32_t counter)
5151
{
@@ -74,6 +74,8 @@ static void rtmr_isr(const void *arg)
7474

7575
k_spinlock_key_t key = k_spin_lock(&lock);
7676

77+
RTMR_REG->INTSTS = 1ul;
78+
7779
rtmr_restart(RTMR_COUNTER_MAX * CYCLES_PER_TICK);
7880

7981
cycles = previous_cnt;
@@ -220,6 +222,8 @@ void arch_busy_wait(uint32_t n_usec)
220222
static int sys_clock_driver_init(void)
221223
{
222224
/* Enable RTMR clock power */
225+
RTMR_REG->INTSTS = 1ul;
226+
NVIC_ClearPendingIRQ(DT_INST_IRQN(0));
223227

224228
SYSTEM_Type *sys_reg = RTS5912_SCCON_REG_BASE;
225229

0 commit comments

Comments
 (0)