1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright (C) 2020 Arm Limited 4 */ 5 6 #define pr_fmt(fmt) "smccc: " fmt 7 8 #include <linux/cache.h> 9 #include <linux/init.h> 10 #include <linux/arm-smccc.h> 11 #include <linux/kernel.h> 12 #include <asm/archrandom.h> 13 14 static u32 smccc_version = ARM_SMCCC_VERSION_1_0; 15 static enum arm_smccc_conduit smccc_conduit = SMCCC_CONDUIT_NONE; 16 17 bool __ro_after_init smccc_trng_available = false; 18 u64 __ro_after_init smccc_has_sve_hint = false; 19 20 void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit) 21 { 22 smccc_version = version; 23 smccc_conduit = conduit; 24 25 smccc_trng_available = smccc_probe_trng(); 26 if (IS_ENABLED(CONFIG_ARM64_SVE) && 27 smccc_version >= ARM_SMCCC_VERSION_1_3) 28 smccc_has_sve_hint = true; 29 } 30 31 enum arm_smccc_conduit arm_smccc_1_1_get_conduit(void) 32 { 33 if (smccc_version < ARM_SMCCC_VERSION_1_1) 34 return SMCCC_CONDUIT_NONE; 35 36 return smccc_conduit; 37 } 38 EXPORT_SYMBOL_GPL(arm_smccc_1_1_get_conduit); 39 40 u32 arm_smccc_get_version(void) 41 { 42 return smccc_version; 43 } 44 EXPORT_SYMBOL_GPL(arm_smccc_get_version); 45