Skip to content

Commit b9c836b

Browse files
michalsieroncarlescufi
authored andcommitted
timer: litex_timer: Use LiteX HAL
Use LiteX HAL functions instead of `sys_read*` or `sys_write*` functions. They use them inside, but choose which one to use according to configured CSR data width. Signed-off-by: Michal Sieron <[email protected]>
1 parent 2e9154a commit b9c836b

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

drivers/timer/litex_timer.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void litex_timer_irq_handler(const void *device)
3232
{
3333
int key = irq_lock();
3434

35-
sys_write8(TIMER_EV, TIMER_EV_PENDING_ADDR);
35+
litex_write8(TIMER_EV, TIMER_EV_PENDING_ADDR);
3636
sys_clock_announce(1);
3737

3838
irq_unlock(key);
@@ -79,18 +79,14 @@ static int sys_clock_driver_init(const struct device *dev)
7979
litex_timer_irq_handler, NULL, 0);
8080
irq_enable(TIMER_IRQ);
8181

82-
sys_write8(TIMER_DISABLE, TIMER_EN_ADDR);
82+
litex_write8(TIMER_DISABLE, TIMER_EN_ADDR);
8383

84-
for (int i = 0; i < 4; i++) {
85-
sys_write8(k_ticks_to_cyc_floor32(1) >> (24 - i * 8),
86-
TIMER_RELOAD_ADDR + i * 0x4);
87-
sys_write8(k_ticks_to_cyc_floor32(1) >> (24 - i * 8),
88-
TIMER_LOAD_ADDR + i * 0x4);
89-
}
84+
litex_write32(k_ticks_to_cyc_floor32(1), TIMER_RELOAD_ADDR);
85+
litex_write32(k_ticks_to_cyc_floor32(1), TIMER_LOAD_ADDR);
9086

91-
sys_write8(TIMER_ENABLE, TIMER_EN_ADDR);
92-
sys_write8(sys_read8(TIMER_EV_PENDING_ADDR), TIMER_EV_PENDING_ADDR);
93-
sys_write8(TIMER_EV, TIMER_EV_ENABLE_ADDR);
87+
litex_write8(TIMER_ENABLE, TIMER_EN_ADDR);
88+
litex_write8(litex_read8(TIMER_EV_PENDING_ADDR), TIMER_EV_PENDING_ADDR);
89+
litex_write8(TIMER_EV, TIMER_EV_ENABLE_ADDR);
9490

9591
return 0;
9692
}

0 commit comments

Comments
 (0)