* [PATCH 1/5] kvx: Fix barebox build for kvx
2024-06-17 13:43 Update kvx support jvetter
@ 2024-06-17 13:43 ` jvetter
2024-06-18 6:13 ` Sascha Hauer
2024-06-17 13:43 ` [PATCH 2/5] kvx: Add 'stop' instruction to power down sequence jvetter
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: jvetter @ 2024-06-17 13:43 UTC (permalink / raw)
To: barebox; +Cc: ysionneau, jborne, jhascoet, clement, Julian Vetter
From: Julian Vetter <jvetter@kalrayinc.com>
Add <linux/bug.h> to arch/kvx/lib/dma-default.c
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
---
arch/kvx/lib/dma-default.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/kvx/lib/dma-default.c b/arch/kvx/lib/dma-default.c
index 1d37fb27a6..0ea5b6c59a 100644
--- a/arch/kvx/lib/dma-default.c
+++ b/arch/kvx/lib/dma-default.c
@@ -7,6 +7,7 @@
#include <asm/cache.h>
#include <asm/sfr.h>
#include <asm/sys_arch.h>
+#include <linux/bug.h>
/*
* The implementation of arch should follow the following rules:
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/5] kvx: Add 'stop' instruction to power down sequence
2024-06-17 13:43 Update kvx support jvetter
2024-06-17 13:43 ` [PATCH 1/5] kvx: Fix barebox build for kvx jvetter
@ 2024-06-17 13:43 ` jvetter
2024-06-17 13:43 ` [PATCH 3/5] kvx: robustify i/d cache startup jvetter
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: jvetter @ 2024-06-17 13:43 UTC (permalink / raw)
To: barebox; +Cc: ysionneau, jborne, jhascoet, clement, Julian Vetter
From: Julian Vetter <jvetter@kalrayinc.com>
If the magic syscall of 0xfff returns, power down the core with the proper
'stop' instruction.
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Reviewed-by: Jonathan Borne <jborne@kalrayinc.com>
---
arch/kvx/lib/poweroff.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/arch/kvx/lib/poweroff.c b/arch/kvx/lib/poweroff.c
index 3ffda026b3..d776cb0877 100644
--- a/arch/kvx/lib/poweroff.c
+++ b/arch/kvx/lib/poweroff.c
@@ -7,6 +7,8 @@
#include <common.h>
#include <poweroff.h>
+#include <asm/sfr.h>
+
static void __noreturn kvx_poweroff(struct poweroff_handler *handler)
{
register int status asm("r0") = 0;
@@ -14,9 +16,18 @@ static void __noreturn kvx_poweroff(struct poweroff_handler *handler)
shutdown_barebox();
asm volatile ("scall 0xfff\n\t;;"
- : : "r"(status)
- : "r1", "r2", "r3", "r4", "r5", "r6", "r7",
- "r8", "memory");
+ :: "r"(status)
+ : "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+ "r8", "r9", "r10", "r11", "memory");
+
+ /* If the scall returns, power down the mppa with stop */
+ kvx_sfr_set_field(WS, WU2, 0);
+
+ asm volatile ("1: stop\n"
+ ";;\n"
+ "goto 1b\n"
+ ";;\n");
+
hang();
}
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/5] kvx: robustify i/d cache startup
2024-06-17 13:43 Update kvx support jvetter
2024-06-17 13:43 ` [PATCH 1/5] kvx: Fix barebox build for kvx jvetter
2024-06-17 13:43 ` [PATCH 2/5] kvx: Add 'stop' instruction to power down sequence jvetter
@ 2024-06-17 13:43 ` jvetter
2024-06-17 13:43 ` [PATCH 4/5] kvx: handle syscalls gracefully jvetter
2024-06-17 13:43 ` [PATCH 5/5] kvx: add support for Coolidge V1/V2 march selection jvetter
4 siblings, 0 replies; 7+ messages in thread
From: jvetter @ 2024-06-17 13:43 UTC (permalink / raw)
To: barebox; +Cc: ysionneau, jborne, jhascoet, clement, Julian Vetter
From: Julian Hascoet <jhascoet@kalrayinc.com>
Make sure the i/d caches start clean after enabling them. Also, make
sure there are no outstanding loads and/or stores before enabling them.
This might fix incoherency issues between caches and memory during the
boot of barebox.
Signed-off-by: Julien Hascoet <jhascoet@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Reviewed-by: Jonathan Borne <jborne@kalrayinc.com>
---
arch/kvx/cpu/start.S | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/kvx/cpu/start.S b/arch/kvx/cpu/start.S
index 342c7d38a5..853676a836 100644
--- a/arch/kvx/cpu/start.S
+++ b/arch/kvx/cpu/start.S
@@ -50,10 +50,21 @@ ENTRY(kvx_start)
;;
/* Setup default processor status */
make $r25 = PS_WFXL_START_VALUE
+ /* Make sure there is no outstanding
+ * load(s)/store(s) before dcache enable
+ */
+ fence
;;
wfxl $ps, $r25
;;
+ /* Make sure icache starts clean */
+ i1inval
+ ;;
+ barrier
+ ;;
make $r25 = PCR_WFXM_START_VALUE
+ /* Make sure dcache starts clean */
+ d1inval
;;
wfxm $pcr, $r25
;;
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/5] kvx: handle syscalls gracefully
2024-06-17 13:43 Update kvx support jvetter
` (2 preceding siblings ...)
2024-06-17 13:43 ` [PATCH 3/5] kvx: robustify i/d cache startup jvetter
@ 2024-06-17 13:43 ` jvetter
2024-06-17 13:43 ` [PATCH 5/5] kvx: add support for Coolidge V1/V2 march selection jvetter
4 siblings, 0 replies; 7+ messages in thread
From: jvetter @ 2024-06-17 13:43 UTC (permalink / raw)
To: barebox; +Cc: ysionneau, jborne, jhascoet, clement, Julian Vetter
From: Clement Leger <clement@clement-leger.fr>
Upon syscall, return to caller via 'rfe' (return from exception)
without any modification or handling.
Signed-off-by: Clement Leger <clement@clement-leger.fr>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Reviewed-by: Jonathan Borne <jborne@kalrayinc.com>
---
arch/kvx/cpu/exception.S | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/arch/kvx/cpu/exception.S b/arch/kvx/cpu/exception.S
index 0017e8ea12..a00e2f93b8 100644
--- a/arch/kvx/cpu/exception.S
+++ b/arch/kvx/cpu/exception.S
@@ -21,4 +21,15 @@ ENDPROC(kvx_ ## __type ## _early_handler)
exception_stub(debug)
exception_stub(trap)
exception_stub(interrupt)
-exception_stub(syscall)
+
+/**
+ * The only time this handle syscalls is when debug routines are not present
+ * (which can happen when booted without JTAG). For instance the "magic
+ * console" uses a syscall catched by the debug routine and if not handled
+ * barebox will crash.
+ */
+.section .exception.syscall, "ax", @progbits
+ENTRY(kvx_syscall_handler):
+ rfe
+ ;;
+ENDPROC(kvx_syscall_handler)
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/5] kvx: add support for Coolidge V1/V2 march selection
2024-06-17 13:43 Update kvx support jvetter
` (3 preceding siblings ...)
2024-06-17 13:43 ` [PATCH 4/5] kvx: handle syscalls gracefully jvetter
@ 2024-06-17 13:43 ` jvetter
4 siblings, 0 replies; 7+ messages in thread
From: jvetter @ 2024-06-17 13:43 UTC (permalink / raw)
To: barebox; +Cc: ysionneau, jborne, jhascoet, clement, Julian Vetter
From: Yann Sionneau <ysionneau@kalrayinc.com>
There is a new version of the MPPA Coolidge chip. Version 2 has some
slight changes in terms of functionality, instructions, etc. So, allow
the system to be built for Coolidge V1 or Coolidge V2.
Signed-off-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Reviewed-by: Jonathan Borne <jborne@kalrayinc.com>
---
arch/kvx/Kconfig | 11 +++++++++++
arch/kvx/Makefile | 7 +++++--
arch/kvx/cpu/barebox.lds.S | 1 -
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/arch/kvx/Kconfig b/arch/kvx/Kconfig
index 2dea8cff82..2e6432f897 100644
--- a/arch/kvx/Kconfig
+++ b/arch/kvx/Kconfig
@@ -37,6 +37,17 @@ config ARCH_TEXT_BASE
hex
default 0x110000000
+choice
+ prompt "KVX CPU variant"
+
+config ARCH_COOLIDGE_V1
+ bool "Coolidge V1 (KV3-1)"
+
+config ARCH_COOLIDGE_V2
+ bool "Coolidge V2 (KV3-2)"
+
+endchoice
+
menu "Board configuration"
config BUILTIN_DTB
diff --git a/arch/kvx/Makefile b/arch/kvx/Makefile
index 9431c9fe18..f47f6d6eca 100644
--- a/arch/kvx/Makefile
+++ b/arch/kvx/Makefile
@@ -15,8 +15,11 @@ DEFAULT_CFLAGS += -DTEXT_BASE=$(CONFIG_TEXT_BASE)
LIBGCC_PATH = $(dir $(shell $(CC) $(KBUILD_CFLAGS) --print-libgcc-file-name))
-KBUILD_CFLAGS += $(DEFAULT_CFLAGS)
-KBUILD_AFLAGS += $(DEFAULT_CFLAGS)
+KVX_BUILD_FLAGS-y = $(DEFAULT_CFLAGS)
+KVX_BUILD_FLAGS-$(CONFIG_ARCH_COOLIDGE_V1) += -march=kv3-1
+KVX_BUILD_FLAGS-$(CONFIG_ARCH_COOLIDGE_V2) += -march=kv3-2
+KBUILD_CFLAGS += $(KVX_BUILD_FLAGS-y)
+KBUILD_AFLAGS += $(KVX_BUILD_FLAGS-y)
KBUILD_LDFLAGS += -m elf64kvx
diff --git a/arch/kvx/cpu/barebox.lds.S b/arch/kvx/cpu/barebox.lds.S
index a22998190f..1edaeae188 100644
--- a/arch/kvx/cpu/barebox.lds.S
+++ b/arch/kvx/cpu/barebox.lds.S
@@ -8,7 +8,6 @@
#include <asm/barebox.lds.h>
OUTPUT_FORMAT("elf64-kvx")
-OUTPUT_ARCH("kvx:kv3-1:64")
SECTIONS
{
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread