stm32mp1: add support for SiP services
authorYann Gautier <yann.gautier@st.com>
Thu, 17 Jan 2019 13:51:25 +0000 (14:51 +0100)
committerYann Gautier <yann.gautier@st.com>
Fri, 18 Jan 2019 14:45:08 +0000 (15:45 +0100)
Change-Id: I9c8241d8cd9d95b647c612dd66dd554d5965c2ac
Signed-off-by: Yann Gautier <yann.gautier@st.com>
Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Signed-off-by: Mathieu Belou <mathieu.belou@st.com>
Signed-off-by: Nicolas Le Bayon <nicolas.le.bayon@st.com>
plat/st/stm32mp1/include/stm32mp1_smc.h [new file with mode: 0644]
plat/st/stm32mp1/services/stm32mp1_svc_setup.c [new file with mode: 0644]
plat/st/stm32mp1/sp_min/sp_min-stm32mp1.mk

diff --git a/plat/st/stm32mp1/include/stm32mp1_smc.h b/plat/st/stm32mp1/include/stm32mp1_smc.h
new file mode 100644 (file)
index 0000000..accd795
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016-2019, STMicroelectronics - All Rights Reserved
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef STM32MP1_SMC_H
+#define STM32MP1_SMC_H
+
+/*
+ * SMC function IDs for STM32 Service queries
+ * STM32 SMC services use the space between 0x82000000 and 0x8200FFFF
+ * like this is defined in SMC calling Convention by ARM
+ * for SiP (silicon Partner)
+ * https://developer.arm.com/docs/den0028/latest
+ */
+
+/* SMC function IDs for SiP Service queries */
+#define STM32_SIP_SVC_CALL_COUNT       0x8200ff00
+#define STM32_SIP_SVC_UID              0x8200ff01
+/*                                     0x8200ff02 is reserved */
+#define STM32_SIP_SVC_VERSION          0x8200ff03
+
+/* STM32 SiP Service Calls version numbers */
+#define STM32_SIP_SVC_VERSION_MAJOR    0x0
+#define STM32_SIP_SVC_VERSION_MINOR    0x1
+
+/* Number of STM32 SiP Calls implemented */
+#define STM32_COMMON_SIP_NUM_CALLS     3
+
+#endif /* STM32MP1_SMC_H */
diff --git a/plat/st/stm32mp1/services/stm32mp1_svc_setup.c b/plat/st/stm32mp1/services/stm32mp1_svc_setup.c
new file mode 100644 (file)
index 0000000..dec2dad
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2014-2019, STMicroelectronics - All Rights Reserved
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/psci/psci.h>
+#include <tools_share/uuid.h>
+
+#include <stm32mp1_smc.h>
+
+/* STM32 SiP Service UUID */
+DEFINE_SVC_UUID2(stm32_sip_svc_uid,
+                0xa778aa50, 0xf49b, 0x144a, 0x8a, 0x5e,
+                0x26, 0x4d, 0x59, 0x94, 0xc2, 0x14);
+
+/* Setup STM32MP1 Standard Services */
+static int32_t stm32mp1_svc_setup(void)
+{
+       /*
+        * PSCI is the only specification implemented as a Standard Service.
+        * Invoke PSCI setup from here.
+        */
+       return 0;
+}
+
+/*
+ * Top-level Standard Service SMC handler. This handler will in turn dispatch
+ * calls to PSCI SMC handler.
+ */
+static uintptr_t stm32mp1_svc_smc_handler(uint32_t smc_fid, u_register_t x1,
+                                         u_register_t x2, u_register_t x3,
+                                         u_register_t x4, void *cookie,
+                                         void *handle, u_register_t flags)
+{
+       uint32_t ret1 = 0U, ret2 = 0U;
+       bool ret_uid = false, ret2_enabled = false;
+
+       switch (smc_fid) {
+       case STM32_SIP_SVC_CALL_COUNT:
+               ret1 = STM32_COMMON_SIP_NUM_CALLS;
+               break;
+
+       case STM32_SIP_SVC_UID:
+               /* Return UUID to the caller */
+               ret_uid = true;
+               break;
+
+       case STM32_SIP_SVC_VERSION:
+               /* Return the version of current implementation */
+               ret1 = STM32_SIP_SVC_VERSION_MAJOR;
+               ret2 = STM32_SIP_SVC_VERSION_MINOR;
+               ret2_enabled = true;
+               break;
+
+       default:
+               WARN("Unimplemented STM32MP1 Service Call: 0x%x\n", smc_fid);
+               ret1 = SMC_UNK;
+               break;
+       }
+
+       if (ret_uid) {
+               SMC_UUID_RET(handle, stm32_sip_svc_uid);
+       }
+
+       if (ret2_enabled) {
+               SMC_RET2(handle, ret1, ret2);
+       }
+
+       SMC_RET1(handle, ret1);
+}
+
+/* Register Standard Service Calls as runtime service */
+DECLARE_RT_SVC(stm32mp1_sip_svc,
+              OEN_SIP_START,
+              OEN_SIP_END,
+              SMC_TYPE_FAST,
+              stm32mp1_svc_setup,
+              stm32mp1_svc_smc_handler
+);
index 9fde153879489af0d725b0c69688c08df77316e6..f78e43d65b2286c034cf254096e1b805382cd587 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -19,3 +19,6 @@ BL32_SOURCES          +=      drivers/arm/gic/common/gic_common.c     \
 
 # Generic PSCI
 BL32_SOURCES           +=      plat/common/plat_psci_common.c
+
+# stm32mp1 specific services
+BL32_SOURCES           +=      plat/st/stm32mp1/services/stm32mp1_svc_setup.c