trusted_foundations.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (c) 2013, NVIDIA Corporation.
  4. */
  5. /*
  6. * Support for the Trusted Foundations secure monitor.
  7. *
  8. * Trusted Foundation comes active on some ARM consumer devices (most
  9. * Tegra-based devices sold on the market are concerned). Such devices can only
  10. * perform some basic operations, like setting the CPU reset vector, through
  11. * SMC calls to the secure monitor. The calls are completely specific to
  12. * Trusted Foundations, and do *not* follow the SMC calling convention or the
  13. * PSCI standard.
  14. */
  15. #ifndef __FIRMWARE_TRUSTED_FOUNDATIONS_H
  16. #define __FIRMWARE_TRUSTED_FOUNDATIONS_H
  17. #include <linux/printk.h>
  18. #include <linux/bug.h>
  19. #include <linux/of.h>
  20. #include <linux/cpu.h>
  21. #include <linux/smp.h>
  22. #include <linux/types.h>
  23. #include <asm/hardware/cache-l2x0.h>
  24. #include <asm/outercache.h>
  25. #define TF_PM_MODE_LP0 0
  26. #define TF_PM_MODE_LP1 1
  27. #define TF_PM_MODE_LP1_NO_MC_CLK 2
  28. #define TF_PM_MODE_LP2 3
  29. #define TF_PM_MODE_LP2_NOFLUSH_L2 4
  30. #define TF_PM_MODE_NONE 5
  31. struct trusted_foundations_platform_data {
  32. unsigned int version_major;
  33. unsigned int version_minor;
  34. };
  35. #if IS_ENABLED(CONFIG_TRUSTED_FOUNDATIONS)
  36. void register_trusted_foundations(struct trusted_foundations_platform_data *pd);
  37. void of_register_trusted_foundations(void);
  38. bool trusted_foundations_registered(void);
  39. #else /* CONFIG_TRUSTED_FOUNDATIONS */
  40. static inline void tf_dummy_write_sec(unsigned long val, unsigned int reg)
  41. {
  42. }
  43. static inline void register_trusted_foundations(
  44. struct trusted_foundations_platform_data *pd)
  45. {
  46. /*
  47. * If the system requires TF and we cannot provide it, continue booting
  48. * but disable features that cannot be provided.
  49. */
  50. pr_err("No support for Trusted Foundations, continuing in degraded mode.\n");
  51. pr_err("Secondary processors as well as CPU PM will be disabled.\n");
  52. #if IS_ENABLED(CONFIG_CACHE_L2X0)
  53. pr_err("L2X0 cache will be kept disabled.\n");
  54. outer_cache.write_sec = tf_dummy_write_sec;
  55. #endif
  56. #if IS_ENABLED(CONFIG_SMP)
  57. setup_max_cpus = 0;
  58. #endif
  59. cpu_idle_poll_ctrl(true);
  60. }
  61. static inline void of_register_trusted_foundations(void)
  62. {
  63. struct device_node *np = of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations");
  64. if (!np)
  65. return;
  66. of_node_put(np);
  67. /*
  68. * If we find the target should enable TF but does not support it,
  69. * fail as the system won't be able to do much anyway
  70. */
  71. register_trusted_foundations(NULL);
  72. }
  73. static inline bool trusted_foundations_registered(void)
  74. {
  75. return false;
  76. }
  77. #endif /* CONFIG_TRUSTED_FOUNDATIONS */
  78. #endif