diff mbox series

[1/2] riscv: function to retrieve SBI implementation version

Message ID 20211025130935.25373-2-heinrich.schuchardt@canonical.com
State Accepted
Delegated to: Andes
Headers show
Series cmd: sbi: show SBI implementation version | expand

Commit Message

Heinrich Schuchardt Oct. 25, 2021, 1:09 p.m. UTC
Provide function sbi_get_impl_version() to retrieve the SBI implementation
version.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 arch/riscv/include/asm/sbi.h |  1 +
 arch/riscv/lib/sbi.c         | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)

Comments

Leo Liang Oct. 27, 2021, 9:06 a.m. UTC | #1
On Mon, Oct 25, 2021 at 03:09:34PM +0200, Heinrich Schuchardt wrote:
> Provide function sbi_get_impl_version() to retrieve the SBI implementation
> version.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
>  arch/riscv/include/asm/sbi.h |  1 +
>  arch/riscv/lib/sbi.c         | 19 +++++++++++++++++++
>  2 files changed, 20 insertions(+)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
Rick Chen Oct. 28, 2021, 12:17 a.m. UTC | #2
> From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> Sent: Monday, October 25, 2021 9:10 PM
> To: Rick Jian-Zhi Chen(陳建志) <rick@andestech.com>; Leo Yu-Chi Liang(梁育齊) <ycliang@andestech.com>
> Cc: u-boot@lists.denx.de; Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> Subject: [PATCH 1/2] riscv: function to retrieve SBI implementation version
>
> Provide function sbi_get_impl_version() to retrieve the SBI implementation version.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
>  arch/riscv/include/asm/sbi.h |  1 +
>  arch/riscv/lib/sbi.c         | 19 +++++++++++++++++++
>  2 files changed, 20 insertions(+)

Reviewed-by: Rick Chen <rick@andestech.com>
diff mbox series

Patch

diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
index 53ca316180..110ec28ef5 100644
--- a/arch/riscv/include/asm/sbi.h
+++ b/arch/riscv/include/asm/sbi.h
@@ -117,6 +117,7 @@  void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
 void sbi_set_timer(uint64_t stime_value);
 long sbi_get_spec_version(void);
 int sbi_get_impl_id(void);
+int sbi_get_impl_version(long *version);
 int sbi_probe_extension(int ext);
 
 #endif
diff --git a/arch/riscv/lib/sbi.c b/arch/riscv/lib/sbi.c
index 77845a73ca..cf13a2f17e 100644
--- a/arch/riscv/lib/sbi.c
+++ b/arch/riscv/lib/sbi.c
@@ -89,6 +89,25 @@  int sbi_get_impl_id(void)
 	return -ENOTSUPP;
 }
 
+/**
+ * sbi_get_impl_version() - get SBI implementation version
+ *
+ * @version:	pointer to receive version
+ * Return:	0 on success, -ENOTSUPP otherwise
+ */
+int sbi_get_impl_version(long *version)
+{
+	struct sbiret ret;
+
+	ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_VERSION,
+			0, 0, 0, 0, 0, 0);
+	if (ret.error)
+		return -ENOTSUPP;
+	if (version)
+		*version = ret.value;
+	return 0;
+}
+
 /**
  * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
  * @extid: The extension ID to be probed.