Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright (c) 2013, NVIDIA Corporation.
0004  */
0005 
0006 /*
0007  * Support for the Trusted Foundations secure monitor.
0008  *
0009  * Trusted Foundation comes active on some ARM consumer devices (most
0010  * Tegra-based devices sold on the market are concerned). Such devices can only
0011  * perform some basic operations, like setting the CPU reset vector, through
0012  * SMC calls to the secure monitor. The calls are completely specific to
0013  * Trusted Foundations, and do *not* follow the SMC calling convention or the
0014  * PSCI standard.
0015  */
0016 
0017 #ifndef __FIRMWARE_TRUSTED_FOUNDATIONS_H
0018 #define __FIRMWARE_TRUSTED_FOUNDATIONS_H
0019 
0020 #include <linux/printk.h>
0021 #include <linux/bug.h>
0022 #include <linux/of.h>
0023 #include <linux/cpu.h>
0024 #include <linux/smp.h>
0025 #include <linux/types.h>
0026 
0027 #include <asm/hardware/cache-l2x0.h>
0028 #include <asm/outercache.h>
0029 
0030 #define TF_PM_MODE_LP0          0
0031 #define TF_PM_MODE_LP1          1
0032 #define TF_PM_MODE_LP1_NO_MC_CLK    2
0033 #define TF_PM_MODE_LP2          3
0034 #define TF_PM_MODE_LP2_NOFLUSH_L2   4
0035 #define TF_PM_MODE_NONE         5
0036 
0037 struct trusted_foundations_platform_data {
0038     unsigned int version_major;
0039     unsigned int version_minor;
0040 };
0041 
0042 #if IS_ENABLED(CONFIG_TRUSTED_FOUNDATIONS)
0043 
0044 void register_trusted_foundations(struct trusted_foundations_platform_data *pd);
0045 void of_register_trusted_foundations(void);
0046 bool trusted_foundations_registered(void);
0047 
0048 #else /* CONFIG_TRUSTED_FOUNDATIONS */
0049 static inline void tf_dummy_write_sec(unsigned long val, unsigned int reg)
0050 {
0051 }
0052 
0053 static inline void register_trusted_foundations(
0054                    struct trusted_foundations_platform_data *pd)
0055 {
0056     /*
0057      * If the system requires TF and we cannot provide it, continue booting
0058      * but disable features that cannot be provided.
0059      */
0060     pr_err("No support for Trusted Foundations, continuing in degraded mode.\n");
0061     pr_err("Secondary processors as well as CPU PM will be disabled.\n");
0062 #if IS_ENABLED(CONFIG_CACHE_L2X0)
0063     pr_err("L2X0 cache will be kept disabled.\n");
0064     outer_cache.write_sec = tf_dummy_write_sec;
0065 #endif
0066 #if IS_ENABLED(CONFIG_SMP)
0067     setup_max_cpus = 0;
0068 #endif
0069     cpu_idle_poll_ctrl(true);
0070 }
0071 
0072 static inline void of_register_trusted_foundations(void)
0073 {
0074     struct device_node *np = of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations");
0075 
0076     if (!np)
0077         return;
0078     of_node_put(np);
0079     /*
0080      * If we find the target should enable TF but does not support it,
0081      * fail as the system won't be able to do much anyway
0082      */
0083     register_trusted_foundations(NULL);
0084 }
0085 
0086 static inline bool trusted_foundations_registered(void)
0087 {
0088     return false;
0089 }
0090 #endif /* CONFIG_TRUSTED_FOUNDATIONS */
0091 
0092 #endif