soc.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef SOC_H
  7. #define SOC_H
  8. enum plls_id {
  9. ABPLL_ID = 0,
  10. ALPLL_ID,
  11. DPLL_ID,
  12. CPLL_ID,
  13. GPLL_ID,
  14. NPLL_ID,
  15. END_PLL_ID,
  16. };
  17. /*****************************************************************************
  18. * secure timer
  19. *****************************************************************************/
  20. #define TIMER_LOADE_COUNT0 0x00
  21. #define TIMER_LOADE_COUNT1 0x04
  22. #define TIMER_CURRENT_VALUE0 0x08
  23. #define TIMER_CURRENT_VALUE1 0x0C
  24. #define TIMER_CONTROL_REG 0x10
  25. #define TIMER_INTSTATUS 0x18
  26. #define TIMER_EN 0x1
  27. #define STIMER1_BASE (STIME_BASE + 0x20)
  28. #define CYCL_24M_CNT_US(us) (24 * us)
  29. #define CYCL_24M_CNT_MS(ms) (ms * CYCL_24M_CNT_US(1000))
  30. /*****************************************************************************
  31. * sgrf reg, offset
  32. *****************************************************************************/
  33. #define SGRF_SOC_CON(n) (0x0 + (n) * 4)
  34. #define SGRF_BUSDMAC_CON(n) (0x100 + (n) * 4)
  35. #define SGRF_SOC_CON_NS 0xffff0000
  36. /*****************************************************************************
  37. * con6[2]pmusram is security.
  38. * con6[6]stimer is security.
  39. *****************************************************************************/
  40. #define PMUSRAM_S_SHIFT 2
  41. #define PMUSRAM_S 1
  42. #define STIMER_S_SHIFT 6
  43. #define STIMER_S 1
  44. #define SGRF_SOC_CON7_BITS ((0xffffu << 16) | \
  45. (PMUSRAM_S << PMUSRAM_S_SHIFT) | \
  46. (STIMER_S << STIMER_S_SHIFT))
  47. #define SGRF_BUSDMAC_CON0_NS 0xfffcfff8
  48. #define SGRF_BUSDMAC_CON1_NS 0xffff0fff
  49. /*
  50. * sgrf_soc_con1~2, mask and offset
  51. */
  52. #define CPU_BOOT_ADDR_WMASK 0xffff0000
  53. #define CPU_BOOT_ADDR_ALIGN 16
  54. /*****************************************************************************
  55. * cru reg, offset
  56. *****************************************************************************/
  57. #define CRU_SOFTRST_CON 0x300
  58. #define CRU_SOFTRSTS_CON(n) (CRU_SOFTRST_CON + ((n) * 4))
  59. #define CRU_SOFTRSTS_CON_CNT 15
  60. #define SOFTRST_DMA1 0x40004
  61. #define SOFTRST_DMA2 0x10001
  62. #define RST_DMA1_MSK 0x4
  63. #define RST_DMA2_MSK 0x0
  64. #define CRU_CLKSEL_CON 0x100
  65. #define CRU_CLKSELS_CON(i) (CRU_CLKSEL_CON + ((i) * 4))
  66. #define CRU_CLKSEL_CON_CNT 56
  67. #define CRU_CLKGATE_CON 0x200
  68. #define CRU_CLKGATES_CON(i) (CRU_CLKGATE_CON + ((i) * 4))
  69. #define CRU_CLKGATES_CON_CNT 25
  70. #define CRU_GLB_SRST_FST 0x280
  71. #define CRU_GLB_SRST_SND 0x284
  72. #define CRU_GLB_RST_CON 0x388
  73. #define CRU_CONS_GATEID(i) (16 * (i))
  74. #define GATE_ID(reg, bit) ((reg * 16) + bit)
  75. #define PMU_RST_BY_SECOND_SFT (BIT(1) << 2)
  76. #define PMU_RST_NOT_BY_SFT (BIT(1) << 2)
  77. /***************************************************************************
  78. * pll
  79. ***************************************************************************/
  80. #define PLL_PWR_DN_MSK (0x1 << 1)
  81. #define PLL_PWR_DN REG_WMSK_BITS(1, 1, 0x1)
  82. #define PLL_PWR_ON REG_WMSK_BITS(0, 1, 0x1)
  83. #define PLL_RESET REG_WMSK_BITS(1, 5, 0x1)
  84. #define PLL_RESET_RESUME REG_WMSK_BITS(0, 5, 0x1)
  85. #define PLL_BYPASS_MSK (0x1 << 0)
  86. #define PLL_BYPASS_W_MSK (PLL_BYPASS_MSK << 16)
  87. #define PLL_BYPASS REG_WMSK_BITS(1, 0, 0x1)
  88. #define PLL_NO_BYPASS REG_WMSK_BITS(0, 0, 0x1)
  89. #define PLL_MODE_SHIFT 8
  90. #define PLL_MODE_MSK 0x3
  91. #define PLLS_MODE_WMASK (PLL_MODE_MSK << (16 + PLL_MODE_SHIFT))
  92. #define PLL_SLOW 0x0
  93. #define PLL_NORM 0x1
  94. #define PLL_DEEP 0x2
  95. #define PLL_SLOW_BITS REG_WMSK_BITS(PLL_SLOW, 8, 0x3)
  96. #define PLL_NORM_BITS REG_WMSK_BITS(PLL_NORM, 8, 0x3)
  97. #define PLL_DEEP_BITS REG_WMSK_BITS(PLL_DEEP, 8, 0x3)
  98. #define PLL_CONS(id, i) ((id) * 0x10 + ((i) * 4))
  99. #define REG_W_MSK(bits_shift, msk) \
  100. ((msk) << ((bits_shift) + 16))
  101. #define REG_VAL_CLRBITS(val, bits_shift, msk) \
  102. (val & (~(msk << bits_shift)))
  103. #define REG_SET_BITS(bits, bits_shift, msk) \
  104. (((bits) & (msk)) << (bits_shift))
  105. #define REG_WMSK_BITS(bits, bits_shift, msk) \
  106. (REG_W_MSK(bits_shift, msk) | \
  107. REG_SET_BITS(bits, bits_shift, msk))
  108. #define regs_updata_bit_set(addr, shift) \
  109. regs_updata_bits((addr), 0x1, 0x1, (shift))
  110. #define regs_updata_bit_clr(addr, shift) \
  111. regs_updata_bits((addr), 0x0, 0x1, (shift))
  112. void regs_updata_bits(uintptr_t addr, uint32_t val,
  113. uint32_t mask, uint32_t shift);
  114. void soc_sleep_config(void);
  115. void pm_plls_resume(void);
  116. #endif /* SOC_H */