]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: socfpga: smc: Add function to get usercode
authorSiew Chin Lim <elly.siew.chin.lim@intel.com>
Thu, 25 Mar 2021 06:07:45 +0000 (14:07 +0800)
committerLey Foon Tan <ley.foon.tan@intel.com>
Thu, 8 Apr 2021 09:29:13 +0000 (17:29 +0800)
Add function to send mailbox command via SMC to get usercode from SDM.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Ley Foon Tan <ley.foon.tan@intel.com>
arch/arm/mach-socfpga/include/mach/smc_api.h
arch/arm/mach-socfpga/smc_api.c
include/linux/intel-smc.h

index bbefdd8dd980b5ccd75e3d6cbd7550e013704dba..6b5b7eadc6650f30b179fa9f14fbdb9d1fd77ea4 100644 (file)
@@ -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_ */
index 085daba162a8036c5494131746975969974f4d92..8ffc7a472b5b9460ee35de117bb96aba0a579fcd 100644 (file)
@@ -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;
+}
index 68d62be41798e4dacede39ed1eb06f1ee1c78e5a..a54eff43addec7cd5a5928cd64f84cf6de40123d 100644 (file)
@@ -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