tzc380.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef TZC380_H
  7. #define TZC380_H
  8. #include <drivers/arm/tzc_common.h>
  9. #include <lib/utils_def.h>
  10. #define TZC380_CONFIGURATION_OFF U(0x000)
  11. #define ACTION_OFF U(0x004)
  12. #define LOCKDOWN_RANGE_OFF U(0x008)
  13. #define LOCKDOWN_SELECT_OFF U(0x00C)
  14. #define INT_STATUS U(0x010)
  15. #define INT_CLEAR U(0x014)
  16. #define FAIL_ADDRESS_LOW_OFF U(0x020)
  17. #define FAIL_ADDRESS_HIGH_OFF U(0x024)
  18. #define FAIL_CONTROL_OFF U(0x028)
  19. #define FAIL_ID U(0x02c)
  20. #define SPECULATION_CTRL_OFF U(0x030)
  21. #define SECURITY_INV_EN_OFF U(0x034)
  22. #define REGION_SETUP_LOW_OFF(n) U(0x100 + (n) * 0x10)
  23. #define REGION_SETUP_HIGH_OFF(n) U(0x104 + (n) * 0x10)
  24. #define REGION_ATTRIBUTES_OFF(n) U(0x108 + (n) * 0x10)
  25. #define BUILD_CONFIG_AW_SHIFT 8
  26. #define BUILD_CONFIG_AW_MASK U(0x3f)
  27. #define BUILD_CONFIG_NR_SHIFT 0
  28. #define BUILD_CONFIG_NR_MASK U(0xf)
  29. #define ACTION_RV_SHIFT 0
  30. #define ACTION_RV_MASK U(0x3)
  31. #define ACTION_RV_LOWOK U(0x0)
  32. #define ACTION_RV_LOWERR U(0x1)
  33. #define ACTION_RV_HIGHOK U(0x2)
  34. #define ACTION_RV_HIGHERR U(0x3)
  35. /* Speculation is enabled by default. */
  36. #define SPECULATION_CTRL_WRITE_DISABLE BIT_32(1)
  37. #define SPECULATION_CTRL_READ_DISABLE BIT_32(0)
  38. #define INT_STATUS_OVERRUN_SHIFT 1
  39. #define INT_STATUS_OVERRUN_MASK U(0x1)
  40. #define INT_STATUS_STATUS_SHIFT 0
  41. #define INT_STATUS_STATUS_MASK U(0x1)
  42. #define INT_CLEAR_CLEAR_SHIFT 0
  43. #define INT_CLEAR_CLEAR_MASK U(0x1)
  44. #define TZC380_COMPONENT_ID U(0xb105f00d)
  45. #define TZC380_PERIPH_ID_LOW U(0x001bb380)
  46. #define TZC380_PERIPH_ID_HIGH U(0x00000004)
  47. #define TZC_SP_NS_W BIT_32(0)
  48. #define TZC_SP_NS_R BIT_32(1)
  49. #define TZC_SP_S_W BIT_32(2)
  50. #define TZC_SP_S_R BIT_32(3)
  51. #define TZC_ATTR_SP_SHIFT 28
  52. #define TZC_ATTR_SP_ALL ((TZC_SP_S_W | TZC_SP_S_R | TZC_SP_NS_W | \
  53. TZC_SP_NS_R) << TZC_ATTR_SP_SHIFT)
  54. #define TZC_ATTR_SP_S_RW ((TZC_SP_S_W | TZC_SP_S_R) << \
  55. TZC_ATTR_SP_SHIFT)
  56. #define TZC_ATTR_SP_NS_RW ((TZC_SP_NS_W | TZC_SP_NS_R) << \
  57. TZC_ATTR_SP_SHIFT)
  58. #define TZC_REGION_SIZE_32K U(0xe)
  59. #define TZC_REGION_SIZE_64K U(0xf)
  60. #define TZC_REGION_SIZE_128K U(0x10)
  61. #define TZC_REGION_SIZE_256K U(0x11)
  62. #define TZC_REGION_SIZE_512K U(0x12)
  63. #define TZC_REGION_SIZE_1M U(0x13)
  64. #define TZC_REGION_SIZE_2M U(0x14)
  65. #define TZC_REGION_SIZE_4M U(0x15)
  66. #define TZC_REGION_SIZE_8M U(0x16)
  67. #define TZC_REGION_SIZE_16M U(0x17)
  68. #define TZC_REGION_SIZE_32M U(0x18)
  69. #define TZC_REGION_SIZE_64M U(0x19)
  70. #define TZC_REGION_SIZE_128M U(0x1a)
  71. #define TZC_REGION_SIZE_256M U(0x1b)
  72. #define TZC_REGION_SIZE_512M U(0x1c)
  73. #define TZC_REGION_SIZE_1G U(0x1d)
  74. #define TZC_REGION_SIZE_2G U(0x1e)
  75. #define TZC_REGION_SIZE_4G U(0x1f)
  76. #define TZC_REGION_SIZE_8G U(0x20)
  77. #define TZC_REGION_SIZE_16G U(0x21)
  78. #define TZC_REGION_SIZE_32G U(0x22)
  79. #define TZC_REGION_SIZE_64G U(0x23)
  80. #define TZC_REGION_SIZE_128G U(0x24)
  81. #define TZC_REGION_SIZE_256G U(0x25)
  82. #define TZC_REGION_SIZE_512G U(0x26)
  83. #define TZC_REGION_SIZE_1T U(0x27)
  84. #define TZC_REGION_SIZE_2T U(0x28)
  85. #define TZC_REGION_SIZE_4T U(0x29)
  86. #define TZC_REGION_SIZE_8T U(0x2a)
  87. #define TZC_REGION_SIZE_16T U(0x2b)
  88. #define TZC_REGION_SIZE_32T U(0x2c)
  89. #define TZC_REGION_SIZE_64T U(0x2d)
  90. #define TZC_REGION_SIZE_128T U(0x2e)
  91. #define TZC_REGION_SIZE_256T U(0x2f)
  92. #define TZC_REGION_SIZE_512T U(0x30)
  93. #define TZC_REGION_SIZE_1P U(0x31)
  94. #define TZC_REGION_SIZE_2P U(0x32)
  95. #define TZC_REGION_SIZE_4P U(0x33)
  96. #define TZC_REGION_SIZE_8P U(0x34)
  97. #define TZC_REGION_SIZE_16P U(0x35)
  98. #define TZC_REGION_SIZE_32P U(0x36)
  99. #define TZC_REGION_SIZE_64P U(0x37)
  100. #define TZC_REGION_SIZE_128P U(0x38)
  101. #define TZC_REGION_SIZE_256P U(0x39)
  102. #define TZC_REGION_SIZE_512P U(0x3a)
  103. #define TZC_REGION_SIZE_1E U(0x3b)
  104. #define TZC_REGION_SIZE_2E U(0x3c)
  105. #define TZC_REGION_SIZE_4E U(0x3d)
  106. #define TZC_REGION_SIZE_8E U(0x3e)
  107. #define TZC_REGION_SIZE_16E U(0x3f)
  108. #define TZC_SUBREGION_DIS_SHIFT 0x8
  109. #define TZC_SUBREGION_DIS_MASK U(0xff)
  110. #define TZC_ATTR_SUBREG_DIS(s) (((s) & TZC_SUBREGION_DIS_MASK) \
  111. << TZC_SUBREGION_DIS_SHIFT)
  112. #define TZC_REGION_SIZE_SHIFT 0x1
  113. #define TZC_REGION_SIZE_MASK U(0x7e)
  114. #define TZC_ATTR_REGION_SIZE(s) ((s) << TZC_REGION_SIZE_SHIFT)
  115. #define TZC_ATTR_REGION_EN_SHIFT 0x0
  116. #define TZC_ATTR_REGION_EN_MASK U(0x1)
  117. #define TZC_ATTR_REGION_EN
  118. #define TZC_ATTR_REGION_ENABLE U(0x1)
  119. #define TZC_ATTR_REGION_DISABLE U(0x0)
  120. #define REGION_MAX 16
  121. void tzc380_init(uintptr_t base);
  122. void tzc380_configure_region(uint8_t region,
  123. uintptr_t region_base,
  124. unsigned int attr);
  125. void tzc380_set_action(unsigned int action);
  126. static inline void tzc_init(uintptr_t base)
  127. {
  128. tzc380_init(base);
  129. }
  130. static inline void tzc_configure_region(uint8_t region,
  131. uintptr_t region_base,
  132. unsigned int attr)
  133. {
  134. tzc380_configure_region(region, region_base, attr);
  135. }
  136. static inline void tzc_set_action(unsigned int action)
  137. {
  138. tzc380_set_action(action);
  139. }
  140. #endif /* TZC380_H */