]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
Implement SMCCC_ARCH_SOC_ID SMC call
authorManish V Badarkhe <Manish.Badarkhe@arm.com>
Sat, 22 Feb 2020 08:43:00 +0000 (08:43 +0000)
committerManish V Badarkhe <Manish.Badarkhe@arm.com>
Tue, 17 Mar 2020 10:14:35 +0000 (10:14 +0000)
Implemented SMCCC_ARCH_SOC_ID call in order to get below
SOC information:

1. SOC revision
2. SOC version

Implementation done using below SMCCC specification document:
https://developer.arm.com/docs/den0028/c

Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
Change-Id: Ie0595f1c345a6429a6fb4a7f05534a0ca9c9a48b

docs/getting_started/porting-guide.rst
include/plat/arm/common/plat_arm.h
include/plat/common/platform.h
include/services/arm_arch_svc.h
plat/arm/common/arm_common.c
plat/common/plat_bl_common.c
services/arm_arch_svc/arm_arch_svc_setup.c

index d634d2e7063b8d893fc5feb90298c5e5ebd25752..d6572f50771d47acd50b9ae23c9fcc3b3ff75367 100644 (file)
@@ -1116,6 +1116,35 @@ can override the common implementation to define a different prefix string for
 the log output. The implementation should be robust to future changes that
 increase the number of log levels.
 
+Function : plat_get_soc_version()
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+    Argument : void
+    Return   : int32_t
+
+This function returns soc version which mainly consist of below fields
+
+::
+
+    soc_version[30:24] = JEP-106 continuation code for the SiP
+    soc_version[23:16] = JEP-106 identification code with parity bit for the SiP
+
+Function : plat_get_soc_revision()
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+    Argument : void
+    Return   : int32_t
+
+This function returns soc revision in below format
+
+::
+
+    soc_revision[0:30] = SOC revision of specific SOC
+
 Modifications specific to a Boot Loader stage
 ---------------------------------------------
 
index 6c2925afa802bcc26744b7580bfb72a6561553f5..a84047aac52463832778d7eeca648d2deb6ec6a7 100644 (file)
@@ -148,6 +148,12 @@ void arm_setup_romlib(void);
 #define ARM_ROTPK_DEVEL_RSA_ID         2
 #define ARM_ROTPK_DEVEL_ECDSA_ID       3
 
+/* Defines used to retrieve ARM SOC revision */
+#define ARM_SOC_CONTINUATION_CODE      U(0x4)
+#define ARM_SOC_IDENTIFICATION_CODE    U(0x3B)
+#define ARM_SOC_CONTINUATION_SHIFT     U(24)
+#define ARM_SOC_IDENTIFICATION_SHIFT   U(16)
+
 /* IO storage utility functions */
 int arm_io_setup(void);
 
@@ -323,4 +329,7 @@ extern const unsigned int arm_pm_idle_states[];
 void plat_arm_secure_wdt_start(void);
 void plat_arm_secure_wdt_stop(void);
 
+/* Get SOC-ID of ARM platform */
+uint32_t plat_arm_get_soc_id(void);
+
 #endif /* PLAT_ARM_H */
index 5b5ebb97316abd4884886d425e060476459e80a8..e4431d2f03e991cf783fb430114865b63268d257 100644 (file)
@@ -322,4 +322,14 @@ void plat_flush_next_bl_params(void);
  */
 unsigned int platform_core_pos_helper(unsigned long mpidr);
 
+/*
+ * Optional function to get SOC version
+ */
+int32_t plat_get_soc_version(void);
+
+/*
+ * Optional function to get SOC revision
+ */
+int32_t plat_get_soc_revision(void);
+
 #endif /* PLATFORM_H */
index 1cb2038c6a2edf12e7a05c121f16d4050af4d1df..5bbd8bb6c51d0a15a56ecab6024db39f9f2e1f3b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -9,7 +9,11 @@
 
 #define SMCCC_VERSION                  U(0x80000000)
 #define SMCCC_ARCH_FEATURES            U(0x80000001)
+#define SMCCC_ARCH_SOC_ID              U(0x80000002)
 #define SMCCC_ARCH_WORKAROUND_1                U(0x80008000)
 #define SMCCC_ARCH_WORKAROUND_2                U(0x80007FFF)
 
+#define SMCCC_GET_SOC_VERSION          U(0)
+#define SMCCC_GET_SOC_REVISION         U(1)
+
 #endif /* ARM_ARCH_SVC_H */
index d1eee08d127400dd9aa7530a46367c1e3b2b3c88..60c777ed8355194973afce4f1b388a625963b8b4 100644 (file)
@@ -25,6 +25,9 @@
  * conflicts with the definition in plat/common. */
 #pragma weak plat_get_syscnt_freq2
 
+/* Get ARM SOC-ID */
+#pragma weak plat_arm_get_soc_id
+
 /*******************************************************************************
  * Changes the memory attributes for the region of mapped memory where the BL
  * image's translation tables are located such that the tables will have
@@ -231,3 +234,22 @@ int plat_sdei_validate_entry_point(uintptr_t ep, unsigned int client_mode)
        return arm_validate_ns_entrypoint(pa);
 }
 #endif
+
+/*
+ * Weak function to get ARM platform SOC-ID, Always return SOC-ID=0
+ * ToDo: Get proper SOC-ID for every ARM platform and define this
+ *       function separately for every ARM platform.
+ */
+uint32_t plat_arm_get_soc_id(void)
+{
+       return 0U;
+}
+
+/* Get SOC version */
+int32_t plat_get_soc_version(void)
+{
+       return (int32_t)
+               ((ARM_SOC_IDENTIFICATION_CODE << ARM_SOC_IDENTIFICATION_SHIFT)
+                | (ARM_SOC_CONTINUATION_CODE << ARM_SOC_CONTINUATION_SHIFT)
+                | plat_arm_get_soc_id());
+}
index de6c1d176868e5eba5f340a06c311fc3e87da8a3..d38fc6f75b20da5a3ccb7dc58883f4a8b1cce721 100644 (file)
@@ -11,6 +11,7 @@
 #include <common/debug.h>
 #include <lib/xlat_tables/xlat_tables_compat.h>
 #include <plat/common/platform.h>
+#include <smccc_helpers.h>
 #include <tools_share/firmware_encrypted.h>
 
 /*
 #pragma weak bl2_plat_handle_post_image_load
 #pragma weak plat_try_next_boot_source
 #pragma weak plat_get_enc_key_info
+#pragma weak plat_get_soc_version
+#pragma weak plat_get_soc_revision
+
+int32_t plat_get_soc_version(void)
+{
+       return SMC_ARCH_CALL_NOT_SUPPORTED;
+}
+
+int32_t plat_get_soc_revision(void)
+{
+       return SMC_ARCH_CALL_NOT_SUPPORTED;
+}
 
 void bl2_el3_plat_prepare_exit(void)
 {
index 6dac56ec81a96c4f527fcaf533557eeead5c4fef..ba539309de3262e99f89055b1a89439da9bae8e4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 #include <lib/smccc.h>
 #include <services/arm_arch_svc.h>
 #include <smccc_helpers.h>
+#include <plat/common/platform.h>
 
 static int32_t smccc_version(void)
 {
        return MAKE_SMCCC_VERSION(SMCCC_MAJOR_VERSION, SMCCC_MINOR_VERSION);
 }
 
-static int32_t smccc_arch_features(u_register_t arg)
+static int32_t smccc_arch_features(u_register_t arg1, u_register_t arg2)
 {
-       switch (arg) {
+       switch (arg1) {
        case SMCCC_VERSION:
        case SMCCC_ARCH_FEATURES:
                return SMC_OK;
+       case SMCCC_ARCH_SOC_ID:
+               if (arg2 == SMCCC_GET_SOC_REVISION) {
+                       return plat_get_soc_revision();
+               }
+               if (arg2 == SMCCC_GET_SOC_VERSION) {
+                       return plat_get_soc_version();
+               }
+               return SMC_ARCH_CALL_INVAL_PARAM;
 #if WORKAROUND_CVE_2017_5715
        case SMCCC_ARCH_WORKAROUND_1:
                if (check_wa_cve_2017_5715() == ERRATA_NOT_APPLIES)
@@ -94,7 +103,7 @@ static uintptr_t arm_arch_svc_smc_handler(uint32_t smc_fid,
        case SMCCC_VERSION:
                SMC_RET1(handle, smccc_version());
        case SMCCC_ARCH_FEATURES:
-               SMC_RET1(handle, smccc_arch_features(x1));
+               SMC_RET1(handle, smccc_arch_features(x1, x2));
 #if WORKAROUND_CVE_2017_5715
        case SMCCC_ARCH_WORKAROUND_1:
                /*