mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Update kvx support
@ 2024-06-17 13:43 jvetter
  2024-06-17 13:43 ` [PATCH 1/5] kvx: Fix barebox build for kvx jvetter
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: jvetter @ 2024-06-17 13:43 UTC (permalink / raw)
  To: barebox; +Cc: ysionneau, jborne, jhascoet, clement

This is a small patch series that updates the support of Barebox for
kvx. It contains some minor fixes and some additions that we currently
maintain in our private repository.









^ permalink raw reply	[flat|nested] 7+ messages in thread

* [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

* Re: [PATCH 1/5] kvx: Fix barebox build for kvx
  2024-06-17 13:43 ` [PATCH 1/5] kvx: Fix barebox build for kvx jvetter
@ 2024-06-18  6:13   ` Sascha Hauer
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2024-06-18  6:13 UTC (permalink / raw)
  To: barebox, jvetter; +Cc: ysionneau, jborne, jhascoet, clement


On Mon, 17 Jun 2024 15:43:25 +0200, jvetter@kalrayinc.com wrote:
> Add <linux/bug.h> to arch/kvx/lib/dma-default.c
> 
> 

Applied, thanks!

[1/5] kvx: Fix barebox build for kvx
      https://git.pengutronix.de/cgit/barebox/commit/?id=c084e47d1764 (link may not be stable)
[2/5] kvx: Add 'stop' instruction to power down sequence
      https://git.pengutronix.de/cgit/barebox/commit/?id=ec10ee14e3dd (link may not be stable)
[3/5] kvx: robustify i/d cache startup
      https://git.pengutronix.de/cgit/barebox/commit/?id=7a2b1131307a (link may not be stable)
[4/5] kvx: handle syscalls gracefully
      https://git.pengutronix.de/cgit/barebox/commit/?id=8586e67a013b (link may not be stable)
[5/5] kvx: add support for Coolidge V1/V2 march selection
      https://git.pengutronix.de/cgit/barebox/commit/?id=115f47b183fb (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-06-18  6:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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-18  6:13   ` Sascha Hauer
2024-06-17 13:43 ` [PATCH 2/5] kvx: Add 'stop' instruction to power down sequence jvetter
2024-06-17 13:43 ` [PATCH 3/5] kvx: robustify i/d cache startup 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox