You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by bt...@apache.org on 2021/02/13 23:24:40 UTC

[incubator-nuttx] 02/02: litex: fix mtime and mtimecmp register address

This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 41bddc8461c266263cb760f9eda861206cb2c54a
Author: David Jablonski <da...@gmail.com>
AuthorDate: Fri Feb 12 20:36:18 2021 +0100

    litex: fix mtime and mtimecmp register address
---
 arch/risc-v/src/litex/hardware/litex_memorymap.h  |  2 +-
 arch/risc-v/src/litex/litex_timerisr.c            | 50 +++++------------------
 boards/risc-v/litex/arty_a7/configs/nsh/defconfig |  1 -
 3 files changed, 11 insertions(+), 42 deletions(-)

diff --git a/arch/risc-v/src/litex/hardware/litex_memorymap.h b/arch/risc-v/src/litex/hardware/litex_memorymap.h
index d808590..0420474 100644
--- a/arch/risc-v/src/litex/hardware/litex_memorymap.h
+++ b/arch/risc-v/src/litex/hardware/litex_memorymap.h
@@ -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 */
diff --git a/arch/risc-v/src/litex/litex_timerisr.c b/arch/risc-v/src/litex/litex_timerisr.c
index 1ec14d2..a1507ad 100644
--- a/arch/risc-v/src/litex/litex_timerisr.c
+++ b/arch/risc-v/src/litex/litex_timerisr.c
@@ -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);
 
diff --git a/boards/risc-v/litex/arty_a7/configs/nsh/defconfig b/boards/risc-v/litex/arty_a7/configs/nsh/defconfig
index 46675ed..3d50afc 100644
--- a/boards/risc-v/litex/arty_a7/configs/nsh/defconfig
+++ b/boards/risc-v/litex/arty_a7/configs/nsh/defconfig
@@ -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