pmu.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /*
  2. * Copyright (c) 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. /* Needed aligned 16 bytes for sp stack top */
  9. #define PSRAM_SP_TOP ((PMUSRAM_BASE + PMUSRAM_RSIZE) & ~0xf)
  10. /*****************************************************************************
  11. * pmu con,reg
  12. *****************************************************************************/
  13. #define PMU_WKUP_CFG0_LO 0x00
  14. #define PMU_WKUP_CFG0_HI 0x04
  15. #define PMU_WKUP_CFG1_LO 0x08
  16. #define PMU_WKUP_CFG1_HI 0x0c
  17. #define PMU_WKUP_CFG2_LO 0x10
  18. #define PMU_PWRDN_CON 0x18
  19. #define PMU_PWRDN_ST 0x20
  20. #define PMU_PWRMODE_CORE_LO 0x24
  21. #define PMU_PWRMODE_CORE_HI 0x28
  22. #define PMU_PWRMODE_COMMON_CON_LO 0x2c
  23. #define PMU_PWRMODE_COMMON_CON_HI 0x30
  24. #define PMU_SFT_CON 0x34
  25. #define PMU_INT_ST 0x44
  26. #define PMU_BUS_IDLE_REQ 0x64
  27. #define PMU_BUS_IDLE_ST 0x6c
  28. #define PMU_OSC_CNT_LO 0x74
  29. #define PMU_OSC_CNT_HI 0x78
  30. #define PMU_PLLLOCK_CNT_LO 0x7c
  31. #define PMU_PLLLOCK_CNT_HI 0x80
  32. #define PMU_PLLRST_CNT_LO 0x84
  33. #define PMU_PLLRST_CNT_HI 0x88
  34. #define PMU_STABLE_CNT_LO 0x8c
  35. #define PMU_STABLE_CNT_HI 0x90
  36. #define PMU_WAKEUP_RST_CLR_LO 0x9c
  37. #define PMU_WAKEUP_RST_CLR_HI 0xa0
  38. #define PMU_DDR_SREF_ST 0xa4
  39. #define PMU_SYS_REG0_LO 0xa8
  40. #define PMU_SYS_REG0_HI 0xac
  41. #define PMU_SYS_REG1_LO 0xb0
  42. #define PMU_SYS_REG1_HI 0xb4
  43. #define PMU_SYS_REG2_LO 0xb8
  44. #define PMU_SYS_REG2_HI 0xbc
  45. #define PMU_SYS_REG3_LO 0xc0
  46. #define PMU_SYS_REG3_HI 0xc4
  47. #define PMU_SCU_PWRDN_CNT_LO 0xc8
  48. #define PMU_SCU_PWRDN_CNT_HI 0xcc
  49. #define PMU_SCU_PWRUP_CNT_LO 0xd0
  50. #define PMU_SCU_PWRUP_CNT_HI 0xd4
  51. #define PMU_TIMEOUT_CNT_LO 0xd8
  52. #define PMU_TIMEOUT_CNT_HI 0xdc
  53. #define PMU_CPUAPM_CON(cpu) (0xe0 + (cpu) * 0x4)
  54. #define CORES_PM_DISABLE 0x0
  55. #define CLST_CPUS_MSK 0xf
  56. #define PD_CTR_LOOP 500
  57. #define PD_CHECK_LOOP 500
  58. #define WFEI_CHECK_LOOP 500
  59. #define BUS_IDLE_LOOP 1000
  60. enum pmu_wkup_cfg2 {
  61. pmu_cluster_wkup_en = 0,
  62. pmu_gpio_wkup_en = 2,
  63. pmu_sdio_wkup_en = 3,
  64. pmu_sdmmc_wkup_en = 4,
  65. pmu_uart0_wkup_en = 5,
  66. pmu_timer_wkup_en = 6,
  67. pmu_usbdev_wkup_en = 7,
  68. pmu_sft_wkup_en = 8,
  69. pmu_timeout_wkup_en = 10,
  70. };
  71. enum pmu_powermode_core_lo {
  72. pmu_global_int_dis = 0,
  73. pmu_core_src_gt = 1,
  74. pmu_cpu0_pd = 3,
  75. pmu_clr_core = 5,
  76. pmu_scu_pd = 6,
  77. pmu_l2_idle = 8,
  78. pmu_l2_flush = 9,
  79. pmu_clr_bus2main = 10,
  80. pmu_clr_peri2msch = 11,
  81. };
  82. enum pmu_powermode_core_hi {
  83. pmu_apll_pd_en = 3,
  84. pmu_dpll_pd_en = 4,
  85. pmu_cpll_pd_en = 5,
  86. pmu_gpll_pd_en = 6,
  87. pmu_npll_pd_en = 7,
  88. };
  89. enum pmu_powermode_common_lo {
  90. pmu_mode_en = 0,
  91. pmu_ddr_pd_en = 1,
  92. pmu_wkup_rst = 3,
  93. pmu_pll_pd = 4,
  94. pmu_pmu_use_if = 6,
  95. pmu_alive_use_if = 7,
  96. pmu_osc_dis = 8,
  97. pmu_input_clamp = 9,
  98. pmu_sref_enter = 10,
  99. pmu_ddrc_gt = 11,
  100. pmu_ddrio_ret = 12,
  101. pmu_ddrio_ret_deq = 13,
  102. pmu_clr_pmu = 14,
  103. pmu_clr_peri_pmu = 15,
  104. };
  105. enum pmu_powermode_common_hi {
  106. pmu_clr_bus = 0,
  107. pmu_clr_mmc = 1,
  108. pmu_clr_msch = 2,
  109. pmu_clr_nandc = 3,
  110. pmu_clr_gmac = 4,
  111. pmu_clr_vo = 5,
  112. pmu_clr_vi = 6,
  113. pmu_clr_gpu = 7,
  114. pmu_clr_usb = 8,
  115. pmu_clr_vpu = 9,
  116. pmu_clr_crypto = 10,
  117. pmu_wakeup_begin_cfg = 11,
  118. pmu_peri_clk_src_gt = 12,
  119. pmu_bus_clk_src_gt = 13,
  120. };
  121. enum pmu_pd_id {
  122. PD_CPU0 = 0,
  123. PD_CPU1 = 1,
  124. PD_CPU2 = 2,
  125. PD_CPU3 = 3,
  126. PD_SCU = 4,
  127. PD_USB = 5,
  128. PD_DDR = 6,
  129. PD_SDCARD = 8,
  130. PD_CRYPTO = 9,
  131. PD_GMAC = 10,
  132. PD_MMC_NAND = 11,
  133. PD_VPU = 12,
  134. PD_VO = 13,
  135. PD_VI = 14,
  136. PD_GPU = 15,
  137. PD_END = 16,
  138. };
  139. enum pmu_bus_id {
  140. BUS_ID_BUS = 0,
  141. BUS_ID_BUS2MAIN = 1,
  142. BUS_ID_GPU = 2,
  143. BUS_ID_CORE = 3,
  144. BUS_ID_CRYPTO = 4,
  145. BUS_ID_MMC = 5,
  146. BUS_ID_GMAC = 6,
  147. BUS_ID_VO = 7,
  148. BUS_ID_VI = 8,
  149. BUS_ID_SDCARD = 9,
  150. BUS_ID_USB = 10,
  151. BUS_ID_MSCH = 11,
  152. BUS_ID_PERI = 12,
  153. BUS_ID_PMU = 13,
  154. BUS_ID_VPU = 14,
  155. BUS_ID_PERI2MSCH = 15,
  156. };
  157. enum pmu_pd_state {
  158. pmu_pd_on = 0,
  159. pmu_pd_off = 1
  160. };
  161. enum pmu_bus_state {
  162. bus_active = 0,
  163. bus_idle = 1,
  164. };
  165. enum cores_pm_ctr_mode {
  166. core_pwr_pd = 0,
  167. core_pwr_wfi = 1,
  168. core_pwr_wfi_int = 2
  169. };
  170. enum pmu_cores_pm_by_wfi {
  171. core_pm_en = 0,
  172. core_pm_int_wakeup_en,
  173. core_pm_dis_int,
  174. core_pm_sft_wakeup_en
  175. };
  176. /*****************************************************************************
  177. * pmu_sgrf
  178. *****************************************************************************/
  179. #define PMUSGRF_SOC_CON(i) ((i) * 0x4)
  180. /*****************************************************************************
  181. * pmu_grf
  182. *****************************************************************************/
  183. #define GPIO0A_IOMUX 0x0
  184. #define GPIO0B_IOMUX 0x4
  185. #define GPIO0C_IOMUX 0x8
  186. #define GPIO0A_PULL 0x10
  187. #define GPIO0L_SMT 0x38
  188. #define GPIO0H_SMT 0x3c
  189. #define PMUGRF_SOC_CON(i) (0x100 + (i) * 4)
  190. #define PMUGRF_PVTM_CON0 0x180
  191. #define PMUGRF_PVTM_CON1 0x184
  192. #define PMUGRF_PVTM_ST0 0x190
  193. #define PMUGRF_PVTM_ST1 0x194
  194. #define PVTM_CALC_CNT 0x200
  195. #define PMUGRF_OS_REG(n) (0x200 + (n) * 4)
  196. #define GPIO0A6_IOMUX_MSK (0x3 << 12)
  197. #define GPIO0A6_IOMUX_GPIO (0x0 << 12)
  198. #define GPIO0A6_IOMUX_RSTOUT (0x1 << 12)
  199. #define GPIO0A6_IOMUX_SHTDN (0x2 << 12)
  200. enum px30_pmugrf_pvtm_con0 {
  201. pgrf_pvtm_st = 0,
  202. pgrf_pvtm_en = 1,
  203. pgrf_pvtm_div = 2,
  204. };
  205. /*****************************************************************************
  206. * pmu_cru
  207. *****************************************************************************/
  208. #define CRU_PMU_MODE 0x20
  209. #define CRU_PMU_CLKSEL_CON 0x40
  210. #define CRU_PMU_CLKSELS_CON(i) (CRU_PMU_CLKSEL_CON + (i) * 4)
  211. #define CRU_PMU_CLKSEL_CON_CNT 5
  212. #define CRU_PMU_CLKGATE_CON 0x80
  213. #define CRU_PMU_CLKGATES_CON(i) (CRU_PMU_CLKGATE_CON + (i) * 4)
  214. #define CRU_PMU_CLKGATE_CON_CNT 2
  215. #define CRU_PMU_ATCS_CON 0xc0
  216. #define CRU_PMU_ATCSS_CON(i) (CRU_PMU_ATCS_CON + (i) * 4)
  217. #define CRU_PMU_ATCS_CON_CNT 2
  218. /*****************************************************************************
  219. * pmusgrf
  220. *****************************************************************************/
  221. #define PMUSGRF_RSTOUT_EN (0x7 << 10)
  222. #define PMUSGRF_RSTOUT_FST 10
  223. #define PMUSGRF_RSTOUT_TSADC 11
  224. #define PMUSGRF_RSTOUT_WDT 12
  225. #define PMUGRF_SOC_CON2_US_WMSK (0x1fff << 16)
  226. #define PMUGRF_SOC_CON2_MAX_341US 0x1fff
  227. #define PMUGRF_SOC_CON2_200US 0x12c0
  228. #define PMUGRF_FAILSAFE_SHTDN_TSADC BIT(0)
  229. #define PMUGRF_FAILSAFE_SHTDN_WDT BIT(1)
  230. /*****************************************************************************
  231. * QOS
  232. *****************************************************************************/
  233. #define CPU_AXI_QOS_ID_COREID 0x00
  234. #define CPU_AXI_QOS_REVISIONID 0x04
  235. #define CPU_AXI_QOS_PRIORITY 0x08
  236. #define CPU_AXI_QOS_MODE 0x0c
  237. #define CPU_AXI_QOS_BANDWIDTH 0x10
  238. #define CPU_AXI_QOS_SATURATION 0x14
  239. #define CPU_AXI_QOS_EXTCONTROL 0x18
  240. #define CPU_AXI_QOS_NUM_REGS 0x07
  241. #define CPU_AXI_CPU_QOS_BASE 0xff508000
  242. #define CPU_AXI_GPU_QOS_BASE 0xff520000
  243. #define CPU_AXI_ISP_128M_QOS_BASE 0xff548000
  244. #define CPU_AXI_ISP_RD_QOS_BASE 0xff548080
  245. #define CPU_AXI_ISP_WR_QOS_BASE 0xff548100
  246. #define CPU_AXI_ISP_M1_QOS_BASE 0xff548180
  247. #define CPU_AXI_VIP_QOS_BASE 0xff548200
  248. #define CPU_AXI_RGA_RD_QOS_BASE 0xff550000
  249. #define CPU_AXI_RGA_WR_QOS_BASE 0xff550080
  250. #define CPU_AXI_VOP_M0_QOS_BASE 0xff550100
  251. #define CPU_AXI_VOP_M1_QOS_BASE 0xff550180
  252. #define CPU_AXI_VPU_QOS_BASE 0xff558000
  253. #define CPU_AXI_VPU_R128_QOS_BASE 0xff558080
  254. #define CPU_AXI_DCF_QOS_BASE 0xff500000
  255. #define CPU_AXI_DMAC_QOS_BASE 0xff500080
  256. #define CPU_AXI_CRYPTO_QOS_BASE 0xff510000
  257. #define CPU_AXI_GMAC_QOS_BASE 0xff518000
  258. #define CPU_AXI_EMMC_QOS_BASE 0xff538000
  259. #define CPU_AXI_NAND_QOS_BASE 0xff538080
  260. #define CPU_AXI_SDIO_QOS_BASE 0xff538100
  261. #define CPU_AXI_SFC_QOS_BASE 0xff538180
  262. #define CPU_AXI_SDMMC_QOS_BASE 0xff52c000
  263. #define CPU_AXI_USB_HOST_QOS_BASE 0xff540000
  264. #define CPU_AXI_USB_OTG_QOS_BASE 0xff540080
  265. #define PX30_CPU_AXI_SAVE_QOS(array, base) do { \
  266. array[0] = mmio_read_32(base + CPU_AXI_QOS_ID_COREID); \
  267. array[1] = mmio_read_32(base + CPU_AXI_QOS_REVISIONID); \
  268. array[2] = mmio_read_32(base + CPU_AXI_QOS_PRIORITY); \
  269. array[3] = mmio_read_32(base + CPU_AXI_QOS_MODE); \
  270. array[4] = mmio_read_32(base + CPU_AXI_QOS_BANDWIDTH); \
  271. array[5] = mmio_read_32(base + CPU_AXI_QOS_SATURATION); \
  272. array[6] = mmio_read_32(base + CPU_AXI_QOS_EXTCONTROL); \
  273. } while (0)
  274. #define PX30_CPU_AXI_RESTORE_QOS(array, base) do { \
  275. mmio_write_32(base + CPU_AXI_QOS_ID_COREID, array[0]); \
  276. mmio_write_32(base + CPU_AXI_QOS_REVISIONID, array[1]); \
  277. mmio_write_32(base + CPU_AXI_QOS_PRIORITY, array[2]); \
  278. mmio_write_32(base + CPU_AXI_QOS_MODE, array[3]); \
  279. mmio_write_32(base + CPU_AXI_QOS_BANDWIDTH, array[4]); \
  280. mmio_write_32(base + CPU_AXI_QOS_SATURATION, array[5]); \
  281. mmio_write_32(base + CPU_AXI_QOS_EXTCONTROL, array[6]); \
  282. } while (0)
  283. #define SAVE_QOS(array, NAME) \
  284. PX30_CPU_AXI_SAVE_QOS(array, CPU_AXI_##NAME##_QOS_BASE)
  285. #define RESTORE_QOS(array, NAME) \
  286. PX30_CPU_AXI_RESTORE_QOS(array, CPU_AXI_##NAME##_QOS_BASE)
  287. #endif /* __PMU_H__ */