se_private.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef SE_PRIVATE_H
  7. #define SE_PRIVATE_H
  8. #include <lib/utils_def.h>
  9. /* SE0 security register */
  10. #define SE0_SECURITY U(0x18)
  11. #define SE0_SECURITY_SE_SOFT_SETTING (((uint32_t)1) << 16U)
  12. /* SE0 config register */
  13. #define SE0_SHA_CONFIG U(0x104)
  14. #define SE0_SHA_TASK_CONFIG U(0x108)
  15. #define SE0_SHA_CONFIG_HW_INIT_HASH ((1U) << 0U)
  16. #define SE0_SHA_CONFIG_HW_INIT_HASH_DISABLE U(0)
  17. #define SE0_CONFIG_ENC_ALG_SHIFT U(12)
  18. #define SE0_CONFIG_ENC_ALG_SHA \
  19. (((uint32_t)3) << SE0_CONFIG_ENC_ALG_SHIFT)
  20. #define SE0_CONFIG_DEC_ALG_SHIFT U(8)
  21. #define SE0_CONFIG_DEC_ALG_NOP \
  22. (((uint32_t)0) << SE0_CONFIG_DEC_ALG_SHIFT)
  23. #define SE0_CONFIG_DST_SHIFT U(2)
  24. #define SE0_CONFIG_DST_HASHREG \
  25. (((uint32_t)1) << SE0_CONFIG_DST_SHIFT)
  26. #define SHA256_HASH_SIZE_BYTES U(256)
  27. #define SE0_CONFIG_ENC_MODE_SHIFT U(24)
  28. #define SE0_CONFIG_ENC_MODE_SHA256 \
  29. (((uint32_t)5) << SE0_CONFIG_ENC_MODE_SHIFT)
  30. /* SHA input message length */
  31. #define SE0_SHA_MSG_LENGTH_0 U(0x11c)
  32. #define SE0_SHA_MSG_LENGTH_1 U(0x120)
  33. #define SE0_SHA_MSG_LENGTH_2 U(0x124)
  34. #define SE0_SHA_MSG_LENGTH_3 U(0x128)
  35. /* SHA input message left */
  36. #define SE0_SHA_MSG_LEFT_0 U(0x12c)
  37. #define SE0_SHA_MSG_LEFT_1 U(0x130)
  38. #define SE0_SHA_MSG_LEFT_2 U(0x134)
  39. #define SE0_SHA_MSG_LEFT_3 U(0x138)
  40. /* SE Hash Result */
  41. #define SE0_SHA_HASH_RESULT_0 U(0x13c)
  42. /* SE OPERATION */
  43. #define SE0_OPERATION_REG_OFFSET U(0x17c)
  44. #define SE0_UNIT_OPERATION_PKT_LASTBUF_SHIFT U(16)
  45. #define SE0_UNIT_OPERATION_PKT_LASTBUF_FIELD \
  46. (((uint32_t)0x1) << SE0_UNIT_OPERATION_PKT_LASTBUF_SHIFT)
  47. #define SE0_OPERATION_SHIFT U(0)
  48. #define SE0_OP_START \
  49. (((uint32_t)0x1) << SE0_OPERATION_SHIFT)
  50. /* SE Interrupt */
  51. #define SE0_SHA_INT_ENABLE U(0x180)
  52. #define SE0_INT_STATUS_REG_OFFSET U(0x184)
  53. #define SE0_INT_OP_DONE_SHIFT U(4)
  54. #define SE0_INT_OP_DONE_CLEAR \
  55. (((uint32_t)0) << SE0_INT_OP_DONE_SHIFT)
  56. #define SE0_INT_OP_DONE(x) \
  57. ((x) & (((uint32_t)0x1) << SE0_INT_OP_DONE_SHIFT))
  58. /* SE SHA status */
  59. #define SE0_SHA_STATUS_0 U(0x188)
  60. #define SE0_SHA_STATUS_IDLE U(0)
  61. /* SE error status */
  62. #define SE0_ERR_STATUS_REG_OFFSET U(0x18c)
  63. #define SE0_ERR_STATUS_CLEAR U(0)
  64. #define SE0_IN_ADDR U(0x10c)
  65. #define SE0_IN_HI_ADDR_HI U(0x110)
  66. #define SE0_IN_HI_ADDR_HI_0_MSB_SHIFT U(24)
  67. /* SE error status */
  68. #define SECURE_SCRATCH_TZDRAM_SHA256_HASH_START SECURE_SCRATCH_RSV63_LO
  69. #define SECURE_SCRATCH_TZDRAM_SHA256_HASH_END SECURE_SCRATCH_RSV66_HI
  70. /*******************************************************************************
  71. * Inline functions definition
  72. ******************************************************************************/
  73. static inline uint32_t tegra_se_read_32(uint32_t offset)
  74. {
  75. return mmio_read_32((uint32_t)(TEGRA_SE0_BASE + offset));
  76. }
  77. static inline void tegra_se_write_32(uint32_t offset, uint32_t val)
  78. {
  79. mmio_write_32(((uint32_t)(TEGRA_SE0_BASE + offset)), val);
  80. }
  81. #endif /* SE_PRIVATE_H */