pmu.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PMU_H
  7. #define PMU_H
  8. #include <pmu_bits.h>
  9. #include <pmu_regs.h>
  10. #include <soc.h>
  11. /* Allocate sp reginon in pmusram */
  12. #define PSRAM_SP_SIZE 0x80
  13. #define PSRAM_SP_BOTTOM (PSRAM_SP_TOP - PSRAM_SP_SIZE)
  14. /*****************************************************************************
  15. * Common define for per soc pmu.h
  16. *****************************************************************************/
  17. /* The ways of cores power domain contorlling */
  18. enum cores_pm_ctr_mode {
  19. core_pwr_pd = 0,
  20. core_pwr_wfi = 1,
  21. core_pwr_wfi_int = 2
  22. };
  23. /*****************************************************************************
  24. * pmu con,reg
  25. *****************************************************************************/
  26. #define PMU_WKUP_CFG(n) ((n) * 4)
  27. #define PMU_CORE_PM_CON(cpu) (0xc0 + (cpu * 4))
  28. /* the shift of bits for cores status */
  29. enum pmu_core_pwrst_shift {
  30. clstl_cpu_wfe = 2,
  31. clstl_cpu_wfi = 6,
  32. clstb_cpu_wfe = 12,
  33. clstb_cpu_wfi = 16
  34. };
  35. #define CKECK_WFE_MSK 0x1
  36. #define CKECK_WFI_MSK 0x10
  37. #define CKECK_WFEI_MSK 0x11
  38. /* Specific features required */
  39. #define AP_PWROFF 0x0a
  40. #define GPIO0A0_SMT_ENABLE BITS_WITH_WMASK(1, 3, 0)
  41. #define GPIO1A6_IOMUX BITS_WITH_WMASK(0, 3, 12)
  42. #define TSADC_INT_PIN 38
  43. #define CORES_PM_DISABLE 0x0
  44. #define PD_CTR_LOOP 10000
  45. #define CHK_CPU_LOOP 500
  46. #define MAX_WAIT_COUNT 1000
  47. #define GRF_SOC_CON4 0x0e210
  48. #define PMUGRF_GPIO0A_SMT 0x0120
  49. #define PMUGRF_SOC_CON0 0x0180
  50. #define CCI_FORCE_WAKEUP WMSK_BIT(8)
  51. #define EXTERNAL_32K WMSK_BIT(0)
  52. #define PLL_PD_HW 0xff
  53. #define IOMUX_CLK_32K 0x00030002
  54. #define NOC_AUTO_ENABLE 0x3fffffff
  55. #define SAVE_QOS(array, NAME) \
  56. RK3399_CPU_AXI_SAVE_QOS(array, CPU_AXI_##NAME##_QOS_BASE)
  57. #define RESTORE_QOS(array, NAME) \
  58. RK3399_CPU_AXI_RESTORE_QOS(array, CPU_AXI_##NAME##_QOS_BASE)
  59. #define RK3399_CPU_AXI_SAVE_QOS(array, base) do { \
  60. array[0] = mmio_read_32(base + CPU_AXI_QOS_ID_COREID); \
  61. array[1] = mmio_read_32(base + CPU_AXI_QOS_REVISIONID); \
  62. array[2] = mmio_read_32(base + CPU_AXI_QOS_PRIORITY); \
  63. array[3] = mmio_read_32(base + CPU_AXI_QOS_MODE); \
  64. array[4] = mmio_read_32(base + CPU_AXI_QOS_BANDWIDTH); \
  65. array[5] = mmio_read_32(base + CPU_AXI_QOS_SATURATION); \
  66. array[6] = mmio_read_32(base + CPU_AXI_QOS_EXTCONTROL); \
  67. } while (0)
  68. #define RK3399_CPU_AXI_RESTORE_QOS(array, base) do { \
  69. mmio_write_32(base + CPU_AXI_QOS_ID_COREID, array[0]); \
  70. mmio_write_32(base + CPU_AXI_QOS_REVISIONID, array[1]); \
  71. mmio_write_32(base + CPU_AXI_QOS_PRIORITY, array[2]); \
  72. mmio_write_32(base + CPU_AXI_QOS_MODE, array[3]); \
  73. mmio_write_32(base + CPU_AXI_QOS_BANDWIDTH, array[4]); \
  74. mmio_write_32(base + CPU_AXI_QOS_SATURATION, array[5]); \
  75. mmio_write_32(base + CPU_AXI_QOS_EXTCONTROL, array[6]); \
  76. } while (0)
  77. struct pmu_slpdata_s {
  78. uint32_t cci_m0_qos[CPU_AXI_QOS_NUM_REGS];
  79. uint32_t cci_m1_qos[CPU_AXI_QOS_NUM_REGS];
  80. uint32_t dmac0_qos[CPU_AXI_QOS_NUM_REGS];
  81. uint32_t dmac1_qos[CPU_AXI_QOS_NUM_REGS];
  82. uint32_t dcf_qos[CPU_AXI_QOS_NUM_REGS];
  83. uint32_t crypto0_qos[CPU_AXI_QOS_NUM_REGS];
  84. uint32_t crypto1_qos[CPU_AXI_QOS_NUM_REGS];
  85. uint32_t pmu_cm0_qos[CPU_AXI_QOS_NUM_REGS];
  86. uint32_t peri_cm1_qos[CPU_AXI_QOS_NUM_REGS];
  87. uint32_t gic_qos[CPU_AXI_QOS_NUM_REGS];
  88. uint32_t sdmmc_qos[CPU_AXI_QOS_NUM_REGS];
  89. uint32_t gmac_qos[CPU_AXI_QOS_NUM_REGS];
  90. uint32_t emmc_qos[CPU_AXI_QOS_NUM_REGS];
  91. uint32_t usb_otg0_qos[CPU_AXI_QOS_NUM_REGS];
  92. uint32_t usb_otg1_qos[CPU_AXI_QOS_NUM_REGS];
  93. uint32_t usb_host0_qos[CPU_AXI_QOS_NUM_REGS];
  94. uint32_t usb_host1_qos[CPU_AXI_QOS_NUM_REGS];
  95. uint32_t gpu_qos[CPU_AXI_QOS_NUM_REGS];
  96. uint32_t video_m0_qos[CPU_AXI_QOS_NUM_REGS];
  97. uint32_t video_m1_r_qos[CPU_AXI_QOS_NUM_REGS];
  98. uint32_t video_m1_w_qos[CPU_AXI_QOS_NUM_REGS];
  99. uint32_t rga_r_qos[CPU_AXI_QOS_NUM_REGS];
  100. uint32_t rga_w_qos[CPU_AXI_QOS_NUM_REGS];
  101. uint32_t vop_big_r[CPU_AXI_QOS_NUM_REGS];
  102. uint32_t vop_big_w[CPU_AXI_QOS_NUM_REGS];
  103. uint32_t vop_little[CPU_AXI_QOS_NUM_REGS];
  104. uint32_t iep_qos[CPU_AXI_QOS_NUM_REGS];
  105. uint32_t isp1_m0_qos[CPU_AXI_QOS_NUM_REGS];
  106. uint32_t isp1_m1_qos[CPU_AXI_QOS_NUM_REGS];
  107. uint32_t isp0_m0_qos[CPU_AXI_QOS_NUM_REGS];
  108. uint32_t isp0_m1_qos[CPU_AXI_QOS_NUM_REGS];
  109. uint32_t hdcp_qos[CPU_AXI_QOS_NUM_REGS];
  110. uint32_t perihp_nsp_qos[CPU_AXI_QOS_NUM_REGS];
  111. uint32_t perilp_nsp_qos[CPU_AXI_QOS_NUM_REGS];
  112. uint32_t perilpslv_nsp_qos[CPU_AXI_QOS_NUM_REGS];
  113. uint32_t sdio_qos[CPU_AXI_QOS_NUM_REGS];
  114. };
  115. extern uint32_t clst_warmboot_data[PLATFORM_CLUSTER_COUNT];
  116. extern void sram_func_set_ddrctl_pll(uint32_t pll_src);
  117. void pmu_power_domains_on(void);
  118. #endif /* PMU_H */