secure.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef SECURE_H
  7. #define SECURE_H
  8. /**************************************************
  9. * sgrf reg, offset
  10. **************************************************/
  11. #define SGRF_SOC_CON0_1(n) (0xc000 + (n) * 4)
  12. #define SGRF_SOC_CON3_7(n) (0xe00c + ((n) - 3) * 4)
  13. #define SGRF_SOC_CON8_15(n) (0x8020 + ((n) - 8) * 4)
  14. #define SGRF_SOC_CON(n) (n < 3 ? SGRF_SOC_CON0_1(n) :\
  15. (n < 8 ? SGRF_SOC_CON3_7(n) :\
  16. SGRF_SOC_CON8_15(n)))
  17. #define SGRF_PMU_SLV_CON0_1(n) (0xc240 + ((n) - 0) * 4)
  18. #define SGRF_SLV_SECURE_CON0_4(n) (0xe3c0 + ((n) - 0) * 4)
  19. #define SGRF_DDRRGN_CON0_16(n) ((n) * 4)
  20. #define SGRF_DDRRGN_CON20_34(n) (0x50 + ((n) - 20) * 4)
  21. /* All of master in ns */
  22. #define SGRF_SOC_ALLMST_NS 0xffff
  23. /* security config for slave */
  24. #define SGRF_SLV_S_WMSK 0xffff0000
  25. #define SGRF_SLV_S_ALL_NS 0x0
  26. /* security config pmu slave ip */
  27. /* All of slaves is ns */
  28. #define SGRF_PMU_SLV_S_NS BIT_WITH_WMSK(0)
  29. /* slaves secure attr is configured */
  30. #define SGRF_PMU_SLV_S_CFGED WMSK_BIT(0)
  31. #define SGRF_PMU_SLV_CRYPTO1_NS WMSK_BIT(1)
  32. #define SGRF_PMUSRAM_S BIT(8)
  33. #define SGRF_INTSRAM_S BIT(13)
  34. /* ddr region */
  35. #define SGRF_DDR_RGN_0_16_WMSK 0x0fff /* DDR RGN 0~16 size mask */
  36. #define SGRF_DDR_RGN_DPLL_CLK BIT_WITH_WMSK(15) /* DDR PLL output clock */
  37. #define SGRF_DDR_RGN_RTC_CLK BIT_WITH_WMSK(14) /* 32K clock for DDR PLL */
  38. /* All security of the DDR RGNs are bypass */
  39. #define SGRF_DDR_RGN_BYPS BIT_WITH_WMSK(9)
  40. /* All security of the DDR RGNs are not bypass */
  41. #define SGRF_DDR_RGN_NO_BYPS WMSK_BIT(9)
  42. /* The MST access the ddr rgn n with secure attribution */
  43. #define SGRF_L_MST_S_DDR_RGN(n) BIT_WITH_WMSK((n))
  44. /* bits[16:8]*/
  45. #define SGRF_H_MST_S_DDR_RGN(n) BIT_WITH_WMSK((n) + 8)
  46. #define SGRF_PMU_CON0 0x0c100
  47. #define SGRF_PMU_CON(n) (SGRF_PMU_CON0 + (n) * 4)
  48. /**************************************************
  49. * secure timer
  50. **************************************************/
  51. /* chanal0~5 */
  52. #define STIMER0_CHN_BASE(n) (STIME_BASE + 0x20 * (n))
  53. /* chanal6~11 */
  54. #define STIMER1_CHN_BASE(n) (STIME_BASE + 0x8000 + 0x20 * (n))
  55. /* low 32 bits */
  56. #define TIMER_END_COUNT0 0x00
  57. /* high 32 bits */
  58. #define TIMER_END_COUNT1 0x04
  59. #define TIMER_CURRENT_VALUE0 0x08
  60. #define TIMER_CURRENT_VALUE1 0x0C
  61. /* low 32 bits */
  62. #define TIMER_INIT_COUNT0 0x10
  63. /* high 32 bits */
  64. #define TIMER_INIT_COUNT1 0x14
  65. #define TIMER_INTSTATUS 0x18
  66. #define TIMER_CONTROL_REG 0x1c
  67. #define TIMER_EN 0x1
  68. #define TIMER_FMODE (0x0 << 1)
  69. #define TIMER_RMODE (0x1 << 1)
  70. /**************************************************
  71. * secure WDT
  72. **************************************************/
  73. #define PCLK_WDT_CA53_GATE_SHIFT 8
  74. #define PCLK_WDT_CM0_GATE_SHIFT 10
  75. /* export secure operating APIs */
  76. void secure_watchdog_gate(void);
  77. __pmusramfunc void secure_watchdog_ungate(void);
  78. void secure_timer_init(void);
  79. void secure_sgrf_init(void);
  80. void secure_sgrf_ddr_rgn_init(void);
  81. __pmusramfunc void sram_secure_timer_init(void);
  82. #endif /* SECURE_H */