qseecom_scm.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2010-2020,2021 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __MACH_SCM_H
  7. #define __MACH_SCM_H
  8. #include <linux/types.h>
  9. #define SCM_SVC_BOOT 0x1
  10. #define SCM_SVC_PIL 0x2
  11. #define SCM_SVC_UTIL 0x3
  12. #define SCM_SVC_TZ 0x4
  13. #define SCM_SVC_IO 0x5
  14. #define SCM_SVC_INFO 0x6
  15. #define SCM_SVC_SSD 0x7
  16. #define SCM_SVC_FUSE 0x8
  17. #define SCM_SVC_PWR 0x9
  18. #define SCM_SVC_MP 0xC
  19. #define SCM_SVC_DCVS 0xD
  20. #define SCM_SVC_ES 0x10
  21. #define SCM_SVC_HDCP 0x11
  22. #define SCM_SVC_MDTP 0x12
  23. #define SCM_SVC_LMH 0x13
  24. #define SCM_SVC_SMMU_PROGRAM 0x15
  25. #define SCM_SVC_QDSS 0x16
  26. #define SCM_SVC_RTIC 0x19
  27. #define SCM_SVC_TZSCHEDULER 0xFC
  28. #define SCM_FUSE_READ 0x7
  29. #define SCM_CMD_HDCP 0x01
  30. /* SCM Features */
  31. #define SCM_SVC_SEC_CAMERA 0xD
  32. #define DEFINE_SCM_BUFFER(__n) \
  33. static char __n[PAGE_SIZE] __aligned(PAGE_SIZE)
  34. #define SCM_BUFFER_SIZE(__buf) sizeof(__buf)
  35. #define SCM_BUFFER_PHYS(__buf) virt_to_phys(__buf)
  36. #define SCM_SIP_FNID(s, c) (((((s) & 0xFF) << 8) | ((c) & 0xFF)) | 0x02000000)
  37. #define SCM_QSEEOS_FNID(s, c) (((((s) & 0xFF) << 8) | ((c) & 0xFF)) | \
  38. 0x32000000)
  39. #define SCM_SVC_ID(s) (((s) & 0xFF00) >> 8)
  40. #define MAX_SCM_ARGS 10
  41. #define MAX_SCM_RETS 3
  42. enum scm_arg_types {
  43. SCM_VAL,
  44. SCM_RO,
  45. SCM_RW,
  46. SCM_BUFVAL,
  47. };
  48. #define SCM_ARGS_IMPL(num, a, b, c, d, e, f, g, h, i, j, ...) (\
  49. (((a) & 0xff) << 4) | \
  50. (((b) & 0xff) << 6) | \
  51. (((c) & 0xff) << 8) | \
  52. (((d) & 0xff) << 10) | \
  53. (((e) & 0xff) << 12) | \
  54. (((f) & 0xff) << 14) | \
  55. (((g) & 0xff) << 16) | \
  56. (((h) & 0xff) << 18) | \
  57. (((i) & 0xff) << 20) | \
  58. (((j) & 0xff) << 22) | \
  59. (num & 0xffff))
  60. #define SCM_ARGS(...) SCM_ARGS_IMPL(__VA_ARGS__, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
  61. struct qseecom_scm_desc {
  62. u32 arginfo;
  63. u64 args[MAX_SCM_ARGS];
  64. u64 ret[MAX_SCM_RETS];
  65. };
  66. #if IS_ENABLED(CONFIG_QCOM_SCM)
  67. int qcom_scm_qseecom_call(u32 cmd_id, struct qseecom_scm_desc *desc,
  68. bool retry);
  69. #else
  70. static inline int qcom_scm_qseecom_call(u32 cmd_id,
  71. struct qseecom_scm_desc *desc,
  72. bool retry)
  73. {
  74. return -ENODEV;
  75. }
  76. #endif
  77. #endif