[PATCH 2/5] kvx: Add 'stop' instruction to power down sequence

jvetter at kalrayinc.com jvetter at kalrayinc.com
Mon Jun 17 06:43:26 PDT 2024


From: Julian Vetter <jvetter at kalrayinc.com>

If the magic syscall of 0xfff returns, power down the core with the proper
'stop' instruction.

Signed-off-by: Julian Vetter <jvetter at kalrayinc.com>
Reviewed-by: Yann Sionneau <ysionneau at kalrayinc.com>
Reviewed-by: Jonathan Borne <jborne at 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








More information about the barebox mailing list