Skip to contentSkip to conversation

arm: socfpga: smc: Add function to get usercode

PATCH New Siew Chin Lim 2 participants 2 messages Mar 25, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: socfpga: smc: Add function to get usercode

Add function to send mailbox command via SMC to get usercode from SDM.

---
 arch/arm/mach-socfpga/include/mach/smc_api.h |  1 +
 arch/arm/mach-socfpga/smc_api.c              | 17 +++++++++++++++++
 include/linux/intel-smc.h                    | 18 ++++++++++++++++++
 3 files changed, 36 insertions(+)
arch/arm/mach-socfpga/include/mach/smc_api.h +1 -0
index bbefdd8dd9..6b5b7eadc6 100644
@@ -9,5 +9,6 @@
 int invoke_smc(u32 func_id, u64 *args, int arg_len, u64 *ret_arg, int ret_len);
 int smc_send_mailbox(u32 cmd, u32 len, u32 *arg, u8 urgent, u32 *resp_buf_len,
 		     u32 *resp_buf);
+int smc_get_usercode(u32 *usercode);
 
 #endif /* _SMC_API_H_ */
arch/arm/mach-socfpga/smc_api.c +17 -0
index 085daba162..8ffc7a472b 100644
@@ -54,3 +54,20 @@ int smc_send_mailbox(u32 cmd, u32 len, u32 *arg, u8 urgent, u32 *resp_buf_len,
 
 	return (int)resp[0];
 }
+
+int smc_get_usercode(u32 *usercode)
+{
+	int ret;
+	u64 resp;
+
+	if (!usercode)
+		return -EINVAL;
+
+	ret = invoke_smc(INTEL_SIP_SMC_GET_USERCODE, NULL, 0,
+			 &resp, 1);
+
+	if (ret == INTEL_SIP_SMC_STATUS_OK)
+		*usercode = (u32)resp;
+
+	return ret;
+}
include/linux/intel-smc.h +18 -0
index 68d62be417..a54eff43ad 100644
@@ -518,4 +518,22 @@ INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_COMPLETED_WRITE)
 #define INTEL_SIP_SMC_MBOX_SEND_CMD \
 	INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_MBOX_SEND_CMD)
 
+/*
+ * Request INTEL_SIP_SMC_GET_USERCODE
+ *
+ * Send mailbox command to get usercode from SDM
+ *
+ * Call register usage:
+ * a0 INTEL_SIP_SMC_GET_USERCODE
+ * a1-7 not used.
+ *
+ * Return status
+ * a0 INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_STATUS_ERROR
+ * a1 User code
+ * a2-3 not used.
+ */
+#define INTEL_SIP_SMC_FUNCID_GET_USERCODE	61
+#define INTEL_SIP_SMC_GET_USERCODE \
+	INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_GET_USERCODE)
+
 #endif
Signature · 1 line
2.13.0
#1 lore raw

PATCH 1/1 arm: socfpga: smc: Add function to get usercode

Quoted 92 lines

-----Original Message-----
From: Lim, Elly Siew Chin <[email protected]>
Sent: Thursday, March 25, 2021 2:08 PM
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>; Gan, Yau Wai <[email protected]>; Lim, Elly Siew Chin <[email protected]>
Subject: [PATCH] arm: socfpga: smc: Add function to get usercode

Add function to send mailbox command via SMC to get usercode from SDM.

---
 arch/arm/mach-socfpga/include/mach/smc_api.h |  1 +
 arch/arm/mach-socfpga/smc_api.c              | 17 +++++++++++++++++
 include/linux/intel-smc.h                    | 18 ++++++++++++++++++
 3 files changed, 36 insertions(+)
arch/arm/mach-socfpga/include/mach/smc_api.h +0 -0
index bbefdd8dd9..6b5b7eadc6 100644
@@ -9,5 +9,6 @@
 int invoke_smc(u32 func_id, u64 *args, int arg_len, u64 *ret_arg, int ret_len);

int smc_send_mailbox(u32 cmd, u32 len, u32 *arg, u8 urgent, u32 *resp_buf_len,

arch/arm/mach-socfpga/include/mach/smc_api.h +1 -0
 		     u32 *resp_buf);
+int smc_get_usercode(u32 *usercode);
 
 #endif /* _SMC_API_H_ */
arch/arm/mach- renamed from arch/arm/mach-socfpga/smc_api.c +0 -0

socfpga/smc_api.c index 085daba162..8ffc7a472b 100644

arch/arm/mach-socfpga/smc_api.c +17 -0
@@ -54,3 +54,20 @@ int smc_send_mailbox(u32 cmd, u32 len, u32 *arg, u8
 urgent, u32 *resp_buf_len,
 
 	return (int)resp[0];
 }
+
+int smc_get_usercode(u32 *usercode)
+{
+	int ret;
+	u64 resp;
+
+	if (!usercode)
+		return -EINVAL;
+
+	ret = invoke_smc(INTEL_SIP_SMC_GET_USERCODE, NULL, 0,
+			 &resp, 1);
+
+	if (ret == INTEL_SIP_SMC_STATUS_OK)
+		*usercode = (u32)resp;
+
+	return ret;
+}
include/linux/intel-smc.h index renamed from include/linux/intel-smc.h +0 -0

68d62be417..a54eff43ad 100644

include/linux/intel-smc.h +0 -0
@@ -518,4 +518,22 @@

INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_ COMPLETED_WRITE)
#define INTEL_SIP_SMC_MBOX_SEND_CMD \

INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_MBOX_
SEND_CMD)

include/linux/intel-smc.h +17 -0
+/*
+ * Request INTEL_SIP_SMC_GET_USERCODE
+ *
+ * Send mailbox command to get usercode from SDM
+ *
+ * Call register usage:
+ * a0 INTEL_SIP_SMC_GET_USERCODE
+ * a1-7 not used.
+ *
+ * Return status
+ * a0 INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_STATUS_ERROR
+ * a1 User code
+ * a2-3 not used.
+ */
+#define INTEL_SIP_SMC_FUNCID_GET_USERCODE	61
+#define INTEL_SIP_SMC_GET_USERCODE \
+
Quoted 6 lines

INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_GET_US
ERCODE)
+
#endif
--
2.13.0