trusted_foundations.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * Support for the Trusted Foundations secure monitor.
  16. *
  17. * Trusted Foundation comes active on some ARM consumer devices (most
  18. * Tegra-based devices sold on the market are concerned). Such devices can only
  19. * perform some basic operations, like setting the CPU reset vector, through
  20. * SMC calls to the secure monitor. The calls are completely specific to
  21. * Trusted Foundations, and do *not* follow the SMC calling convention or the
  22. * PSCI standard.
  23. */
  24. #ifndef __ASM_ARM_TRUSTED_FOUNDATIONS_H
  25. #define __ASM_ARM_TRUSTED_FOUNDATIONS_H
  26. #include <linux/printk.h>
  27. #include <linux/bug.h>
  28. #include <linux/of.h>
  29. #include <linux/cpu.h>
  30. #include <linux/smp.h>
  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. #else /* CONFIG_TRUSTED_FOUNDATIONS */
  39. static inline void register_trusted_foundations(
  40. struct trusted_foundations_platform_data *pd)
  41. {
  42. /*
  43. * If the system requires TF and we cannot provide it, continue booting
  44. * but disable features that cannot be provided.
  45. */
  46. pr_err("No support for Trusted Foundations, continuing in degraded mode.\n");
  47. pr_err("Secondary processors as well as CPU PM will be disabled.\n");
  48. #if IS_ENABLED(CONFIG_SMP)
  49. setup_max_cpus = 0;
  50. #endif
  51. cpu_idle_poll_ctrl(true);
  52. }
  53. static inline void of_register_trusted_foundations(void)
  54. {
  55. /*
  56. * If we find the target should enable TF but does not support it,
  57. * fail as the system won't be able to do much anyway
  58. */
  59. if (of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations"))
  60. register_trusted_foundations(NULL);
  61. }
  62. #endif /* CONFIG_TRUSTED_FOUNDATIONS */
  63. #endif