Alexandre Courbot | d9a1bea | 2013-11-24 15:30:46 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013, NVIDIA Corporation. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | */ |
| 14 | |
| 15 | /* |
| 16 | * Support for the Trusted Foundations secure monitor. |
| 17 | * |
| 18 | * Trusted Foundation comes active on some ARM consumer devices (most |
| 19 | * Tegra-based devices sold on the market are concerned). Such devices can only |
| 20 | * perform some basic operations, like setting the CPU reset vector, through |
| 21 | * SMC calls to the secure monitor. The calls are completely specific to |
| 22 | * Trusted Foundations, and do *not* follow the SMC calling convention or the |
| 23 | * PSCI standard. |
| 24 | */ |
| 25 | |
| 26 | #ifndef __ASM_ARM_TRUSTED_FOUNDATIONS_H |
| 27 | #define __ASM_ARM_TRUSTED_FOUNDATIONS_H |
| 28 | |
| 29 | #include <linux/kconfig.h> |
| 30 | #include <linux/printk.h> |
| 31 | #include <linux/bug.h> |
| 32 | #include <linux/of.h> |
Alexandre Courbot | c3af6d6 | 2014-02-07 13:35:02 +0900 | [diff] [blame] | 33 | #include <linux/cpu.h> |
| 34 | #include <linux/smp.h> |
Alexandre Courbot | d9a1bea | 2013-11-24 15:30:46 +0900 | [diff] [blame] | 35 | |
| 36 | struct trusted_foundations_platform_data { |
| 37 | unsigned int version_major; |
| 38 | unsigned int version_minor; |
| 39 | }; |
| 40 | |
| 41 | #if IS_ENABLED(CONFIG_TRUSTED_FOUNDATIONS) |
| 42 | |
| 43 | void register_trusted_foundations(struct trusted_foundations_platform_data *pd); |
| 44 | void of_register_trusted_foundations(void); |
| 45 | |
| 46 | #else /* CONFIG_TRUSTED_FOUNDATIONS */ |
| 47 | |
| 48 | static inline void register_trusted_foundations( |
| 49 | struct trusted_foundations_platform_data *pd) |
| 50 | { |
| 51 | /* |
Alexandre Courbot | c3af6d6 | 2014-02-07 13:35:02 +0900 | [diff] [blame] | 52 | * If the system requires TF and we cannot provide it, continue booting |
| 53 | * but disable features that cannot be provided. |
Alexandre Courbot | d9a1bea | 2013-11-24 15:30:46 +0900 | [diff] [blame] | 54 | */ |
Alexandre Courbot | c3af6d6 | 2014-02-07 13:35:02 +0900 | [diff] [blame] | 55 | pr_err("No support for Trusted Foundations, continuing in degraded mode.\n"); |
| 56 | pr_err("Secondary processors as well as CPU PM will be disabled.\n"); |
Alexandre Courbot | 3aae97c | 2014-05-23 09:23:32 +0900 | [diff] [blame] | 57 | #if IS_ENABLED(CONFIG_SMP) |
Alexandre Courbot | c3af6d6 | 2014-02-07 13:35:02 +0900 | [diff] [blame] | 58 | setup_max_cpus = 0; |
Alexandre Courbot | 3aae97c | 2014-05-23 09:23:32 +0900 | [diff] [blame] | 59 | #endif |
Alexandre Courbot | c3af6d6 | 2014-02-07 13:35:02 +0900 | [diff] [blame] | 60 | cpu_idle_poll_ctrl(true); |
Alexandre Courbot | d9a1bea | 2013-11-24 15:30:46 +0900 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | static inline void of_register_trusted_foundations(void) |
| 64 | { |
| 65 | /* |
| 66 | * If we find the target should enable TF but does not support it, |
| 67 | * fail as the system won't be able to do much anyway |
| 68 | */ |
Alexandre Courbot | a553b7f | 2014-02-07 13:35:01 +0900 | [diff] [blame] | 69 | if (of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations")) |
Alexandre Courbot | d9a1bea | 2013-11-24 15:30:46 +0900 | [diff] [blame] | 70 | register_trusted_foundations(NULL); |
| 71 | } |
| 72 | #endif /* CONFIG_TRUSTED_FOUNDATIONS */ |
| 73 | |
| 74 | #endif |