mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: jvetter@kalrayinc.com
To: barebox@lists.infradead.org
Cc: ysionneau@kalrayinc.com, jborne@kalrayinc.com,
	jhascoet@kalrayinc.com, clement@clement-leger.fr,
	Julian Vetter <jvetter@kalrayinc.com>
Subject: [PATCH 2/5] kvx: Add 'stop' instruction to power down sequence
Date: Mon, 17 Jun 2024 15:43:26 +0200	[thread overview]
Message-ID: <20240617134329.3671762-3-jvetter@kalrayinc.com> (raw)
In-Reply-To: <20240617134329.3671762-1-jvetter@kalrayinc.com>

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








  parent reply	other threads:[~2024-06-17 13:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` jvetter [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240617134329.3671762-3-jvetter@kalrayinc.com \
    --to=jvetter@kalrayinc.com \
    --cc=barebox@lists.infradead.org \
    --cc=clement@clement-leger.fr \
    --cc=jborne@kalrayinc.com \
    --cc=jhascoet@kalrayinc.com \
    --cc=ysionneau@kalrayinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox