aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-03-17 07:36:14 +0100
committerLeo Yu-Chi Liang <ycliang@andestech.com>2022-04-06 09:40:05 +0800
commitca7e93fa9f6c417a2d260440ff4c0aaded259989 (patch)
treed7af3313526b4c240f4df2c8f8d214d54ba4466d /arch/riscv/lib
parent70ae54bd2579568372e79f69417e5cb568b24b6f (diff)
downloadu-boot-ca7e93fa9f6c417a2d260440ff4c0aaded259989.zip
u-boot-ca7e93fa9f6c417a2d260440ff4c0aaded259989.tar.gz
u-boot-ca7e93fa9f6c417a2d260440ff4c0aaded259989.tar.bz2
riscv: provide missing base extension functions
Provide library functions to read: * machine vendor ID * machine architecture ID * machine implementation ID Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Sean Anderson <seanga2@gmail.com>
Diffstat (limited to 'arch/riscv/lib')
-rw-r--r--arch/riscv/lib/sbi.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/arch/riscv/lib/sbi.c b/arch/riscv/lib/sbi.c
index d427d1b..8724e3a 100644
--- a/arch/riscv/lib/sbi.c
+++ b/arch/riscv/lib/sbi.c
@@ -128,6 +128,71 @@ int sbi_probe_extension(int extid)
}
/**
+ * sbi_get_mvendorid() - get machine vendor ID
+ *
+ * @mimpid: on return machine vendor ID
+ * Return: 0 on success
+ */
+int sbi_get_mvendorid(long *mvendorid)
+{
+ struct sbiret ret;
+
+ ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_MVENDORID,
+ 0, 0, 0, 0, 0, 0);
+ if (ret.error)
+ return -ENOTSUPP;
+
+ if (mvendorid)
+ *mvendorid = ret.value;
+
+ return 0;
+}
+
+/**
+ * sbi_get_marchid() - get machine architecture ID
+ *
+ * @mimpid: on return machine architecture ID
+ * Return: 0 on success
+ */
+int sbi_get_marchid(long *marchid)
+{
+ struct sbiret ret;
+
+ ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_MARCHID,
+ 0, 0, 0, 0, 0, 0);
+
+ if (ret.error)
+ return -ENOTSUPP;
+
+ if (marchid)
+ *marchid = ret.value;
+
+ return 0;
+}
+
+/**
+ * sbi_get_mimpid() - get machine implementation ID
+ *
+ * @mimpid: on return machine implementation ID
+ * Return: 0 on success
+ */
+int sbi_get_mimpid(long *mimpid)
+{
+ struct sbiret ret;
+
+ ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_MIMPID,
+ 0, 0, 0, 0, 0, 0);
+
+ if (ret.error)
+ return -ENOTSUPP;
+
+ if (mimpid)
+ *mimpid = ret.value;
+
+ return 0;
+}
+
+/**
* sbi_srst_reset() - invoke system reset extension
*
* @type: type of reset