mirror of
https://github.com/apache/nuttx.git
synced 2026-05-19 20:06:24 +08:00
litex: fix mtime and mtimecmp register address
This commit is contained in:
committed by
Brennan Ashton
parent
11167857c3
commit
41bddc8461
@@ -33,6 +33,6 @@
|
||||
|
||||
#define LITEX_CPUTIMER_BASE 0xf0000800 /* riscv clint timer */
|
||||
#define LITEX_TIMER0_BASE 0xf0002800
|
||||
#define LITEX_UART0_BASE 0xf0002000 /* 0xf0001000 - : UART0 */
|
||||
#define LITEX_UART0_BASE 0xf0002000 /* 0xf0002000 - : UART0 */
|
||||
|
||||
#endif /* __ARCH_RISCV_SRC_LITEX_HARDWARE_LITEX_MEMORYMAP_H */
|
||||
|
||||
@@ -61,54 +61,24 @@ static bool _b_tick_started = false;
|
||||
|
||||
static inline uint64_t litex_clint_time_read(void)
|
||||
{
|
||||
uint64_t r = getreg8(LITEX_CLINT_MTIME);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIME + 0x04);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIME + 0x08);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIME + 0x0c);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIME + 0x10);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIME + 0x14);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIME + 0x18);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIME + 0x1c);
|
||||
uint64_t r = getreg32(LITEX_CLINT_MTIME);
|
||||
r <<= 32;
|
||||
r |= getreg32(LITEX_CLINT_MTIME + 0x04);
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline uint64_t litex_clint_time_cmp_read(void)
|
||||
{
|
||||
uint64_t r = getreg8(LITEX_CLINT_MTIMECMP);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIMECMP + 0x04);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIMECMP + 0x08);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIMECMP + 0x0c);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIMECMP + 0x10);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIMECMP + 0x14);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIMECMP + 0x18);
|
||||
r <<= 8;
|
||||
r |= getreg8(LITEX_CLINT_MTIMECMP + 0x1c);
|
||||
uint64_t r = getreg32(LITEX_CLINT_MTIMECMP);
|
||||
r <<= 32;
|
||||
r |= getreg32(LITEX_CLINT_MTIMECMP + 0x04);
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline void litex_clint_time_cmp_write(uint64_t v)
|
||||
{
|
||||
putreg8(v >> 56, LITEX_CLINT_MTIMECMP);
|
||||
putreg8(v >> 48, LITEX_CLINT_MTIMECMP + 0x04);
|
||||
putreg8(v >> 40, LITEX_CLINT_MTIMECMP + 0x08);
|
||||
putreg8(v >> 32, LITEX_CLINT_MTIMECMP + 0x0c);
|
||||
putreg8(v >> 24, LITEX_CLINT_MTIMECMP + 0x10);
|
||||
putreg8(v >> 16, LITEX_CLINT_MTIMECMP + 0x14);
|
||||
putreg8(v >> 8, LITEX_CLINT_MTIMECMP + 0x18);
|
||||
putreg8(v, LITEX_CLINT_MTIMECMP + 0x1c);
|
||||
putreg32(v >> 32, LITEX_CLINT_MTIMECMP);
|
||||
putreg32(v, LITEX_CLINT_MTIMECMP + 0x04);
|
||||
}
|
||||
|
||||
/* helper function to set/clear csr */
|
||||
@@ -141,7 +111,7 @@ static void litex_reload_mtimecmp(void)
|
||||
if (!_b_tick_started)
|
||||
{
|
||||
_b_tick_started = true;
|
||||
putreg8(1, LITEX_CLINT_LATCH);
|
||||
putreg32(1, LITEX_CLINT_LATCH);
|
||||
current = litex_clint_time_read();
|
||||
}
|
||||
else
|
||||
@@ -152,7 +122,7 @@ static void litex_reload_mtimecmp(void)
|
||||
next = current + TICK_COUNT;
|
||||
|
||||
litex_clint_time_cmp_write(next);
|
||||
putreg8(1, LITEX_CLINT_LATCH);
|
||||
putreg32(1, LITEX_CLINT_LATCH);
|
||||
csr_set(mie, MIE_MTIE);
|
||||
csr_clear(mip, MIP_MTIP);
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEFAULT_SMALL=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_DISABLE_MQUEUE=y
|
||||
CONFIG_ELF=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXAMPLES_HELLO_STACKSIZE=8192
|
||||
CONFIG_FS_PROCFS=y
|
||||
|
||||
Reference in New Issue
Block a user