mtk_dcm_utils.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. /*
  2. * Copyright (c) 2021, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <lib/mmio.h>
  7. #include <lib/utils_def.h>
  8. #include <mtk_dcm_utils.h>
  9. #define MP_CPUSYS_TOP_ADB_DCM_REG0_MASK (BIT(16) | \
  10. BIT(17) | \
  11. BIT(18) | \
  12. BIT(21))
  13. #define MP_CPUSYS_TOP_ADB_DCM_REG1_MASK (BIT(16) | \
  14. BIT(17) | \
  15. BIT(18))
  16. #define MP_CPUSYS_TOP_ADB_DCM_REG0_ON (BIT(16) | \
  17. BIT(17) | \
  18. BIT(18) | \
  19. BIT(21))
  20. #define MP_CPUSYS_TOP_ADB_DCM_REG1_ON (BIT(16) | \
  21. BIT(17) | \
  22. BIT(18))
  23. #define MP_CPUSYS_TOP_ADB_DCM_REG0_OFF ((0x0 << 16) | \
  24. (0x0 << 17) | \
  25. (0x0 << 18) | \
  26. (0x0 << 21))
  27. #define MP_CPUSYS_TOP_ADB_DCM_REG1_OFF ((0x0 << 16) | \
  28. (0x0 << 17) | \
  29. (0x0 << 18))
  30. bool dcm_mp_cpusys_top_adb_dcm_is_on(void)
  31. {
  32. bool ret = true;
  33. ret &= ((mmio_read_32(MP_CPUSYS_TOP_MP_ADB_DCM_CFG4) &
  34. MP_CPUSYS_TOP_ADB_DCM_REG0_MASK) ==
  35. (unsigned int) MP_CPUSYS_TOP_ADB_DCM_REG0_ON);
  36. ret &= ((mmio_read_32(MP_CPUSYS_TOP_MCUSYS_DCM_CFG0) &
  37. MP_CPUSYS_TOP_ADB_DCM_REG1_MASK) ==
  38. (unsigned int) MP_CPUSYS_TOP_ADB_DCM_REG1_ON);
  39. return ret;
  40. }
  41. void dcm_mp_cpusys_top_adb_dcm(bool on)
  42. {
  43. if (on) {
  44. /* TINFO = "Turn ON DCM 'mp_cpusys_top_adb_dcm'" */
  45. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP_ADB_DCM_CFG4,
  46. MP_CPUSYS_TOP_ADB_DCM_REG0_MASK,
  47. MP_CPUSYS_TOP_ADB_DCM_REG0_ON);
  48. mmio_clrsetbits_32(MP_CPUSYS_TOP_MCUSYS_DCM_CFG0,
  49. MP_CPUSYS_TOP_ADB_DCM_REG1_MASK,
  50. MP_CPUSYS_TOP_ADB_DCM_REG1_ON);
  51. } else {
  52. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_adb_dcm'" */
  53. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP_ADB_DCM_CFG4,
  54. MP_CPUSYS_TOP_ADB_DCM_REG0_MASK,
  55. MP_CPUSYS_TOP_ADB_DCM_REG0_OFF);
  56. mmio_clrsetbits_32(MP_CPUSYS_TOP_MCUSYS_DCM_CFG0,
  57. MP_CPUSYS_TOP_ADB_DCM_REG1_MASK,
  58. MP_CPUSYS_TOP_ADB_DCM_REG1_OFF);
  59. }
  60. }
  61. #define MP_CPUSYS_TOP_APB_DCM_REG0_MASK (BIT(5))
  62. #define MP_CPUSYS_TOP_APB_DCM_REG1_MASK (BIT(8))
  63. #define MP_CPUSYS_TOP_APB_DCM_REG2_MASK (BIT(16))
  64. #define MP_CPUSYS_TOP_APB_DCM_REG0_ON (BIT(5))
  65. #define MP_CPUSYS_TOP_APB_DCM_REG1_ON (BIT(8))
  66. #define MP_CPUSYS_TOP_APB_DCM_REG2_ON (BIT(16))
  67. #define MP_CPUSYS_TOP_APB_DCM_REG0_OFF ((0x0 << 5))
  68. #define MP_CPUSYS_TOP_APB_DCM_REG1_OFF ((0x0 << 8))
  69. #define MP_CPUSYS_TOP_APB_DCM_REG2_OFF ((0x0 << 16))
  70. bool dcm_mp_cpusys_top_apb_dcm_is_on(void)
  71. {
  72. bool ret = true;
  73. ret &= ((mmio_read_32(MP_CPUSYS_TOP_MP_MISC_DCM_CFG0) &
  74. MP_CPUSYS_TOP_APB_DCM_REG0_MASK) ==
  75. (unsigned int) MP_CPUSYS_TOP_APB_DCM_REG0_ON);
  76. ret &= ((mmio_read_32(MP_CPUSYS_TOP_MCUSYS_DCM_CFG0) &
  77. MP_CPUSYS_TOP_APB_DCM_REG1_MASK) ==
  78. (unsigned int) MP_CPUSYS_TOP_APB_DCM_REG1_ON);
  79. ret &= ((mmio_read_32(MP_CPUSYS_TOP_MP0_DCM_CFG0) &
  80. MP_CPUSYS_TOP_APB_DCM_REG2_MASK) ==
  81. (unsigned int) MP_CPUSYS_TOP_APB_DCM_REG2_ON);
  82. return ret;
  83. }
  84. void dcm_mp_cpusys_top_apb_dcm(bool on)
  85. {
  86. if (on) {
  87. /* TINFO = "Turn ON DCM 'mp_cpusys_top_apb_dcm'" */
  88. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP_MISC_DCM_CFG0,
  89. MP_CPUSYS_TOP_APB_DCM_REG0_MASK,
  90. MP_CPUSYS_TOP_APB_DCM_REG0_ON);
  91. mmio_clrsetbits_32(MP_CPUSYS_TOP_MCUSYS_DCM_CFG0,
  92. MP_CPUSYS_TOP_APB_DCM_REG1_MASK,
  93. MP_CPUSYS_TOP_APB_DCM_REG1_ON);
  94. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP0_DCM_CFG0,
  95. MP_CPUSYS_TOP_APB_DCM_REG2_MASK,
  96. MP_CPUSYS_TOP_APB_DCM_REG2_ON);
  97. } else {
  98. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_apb_dcm'" */
  99. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP_MISC_DCM_CFG0,
  100. MP_CPUSYS_TOP_APB_DCM_REG0_MASK,
  101. MP_CPUSYS_TOP_APB_DCM_REG0_OFF);
  102. mmio_clrsetbits_32(MP_CPUSYS_TOP_MCUSYS_DCM_CFG0,
  103. MP_CPUSYS_TOP_APB_DCM_REG1_MASK,
  104. MP_CPUSYS_TOP_APB_DCM_REG1_OFF);
  105. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP0_DCM_CFG0,
  106. MP_CPUSYS_TOP_APB_DCM_REG2_MASK,
  107. MP_CPUSYS_TOP_APB_DCM_REG2_OFF);
  108. }
  109. }
  110. #define MP_CPUSYS_TOP_BUS_PLL_DIV_DCM_REG0_MASK (BIT(11) | \
  111. BIT(24) | \
  112. BIT(25))
  113. #define MP_CPUSYS_TOP_BUS_PLL_DIV_DCM_REG0_ON (BIT(11) | \
  114. BIT(24) | \
  115. BIT(25))
  116. #define MP_CPUSYS_TOP_BUS_PLL_DIV_DCM_REG0_OFF ((0x0 << 11) | \
  117. (0x0 << 24) | \
  118. (0x0 << 25))
  119. bool dcm_mp_cpusys_top_bus_pll_div_dcm_is_on(void)
  120. {
  121. bool ret = true;
  122. ret &= ((mmio_read_32(MP_CPUSYS_TOP_BUS_PLLDIV_CFG) &
  123. MP_CPUSYS_TOP_BUS_PLL_DIV_DCM_REG0_MASK) ==
  124. (unsigned int) MP_CPUSYS_TOP_BUS_PLL_DIV_DCM_REG0_ON);
  125. return ret;
  126. }
  127. void dcm_mp_cpusys_top_bus_pll_div_dcm(bool on)
  128. {
  129. if (on) {
  130. /* TINFO = "Turn ON DCM 'mp_cpusys_top_bus_pll_div_dcm'" */
  131. mmio_clrsetbits_32(MP_CPUSYS_TOP_BUS_PLLDIV_CFG,
  132. MP_CPUSYS_TOP_BUS_PLL_DIV_DCM_REG0_MASK,
  133. MP_CPUSYS_TOP_BUS_PLL_DIV_DCM_REG0_ON);
  134. } else {
  135. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_bus_pll_div_dcm'" */
  136. mmio_clrsetbits_32(MP_CPUSYS_TOP_BUS_PLLDIV_CFG,
  137. MP_CPUSYS_TOP_BUS_PLL_DIV_DCM_REG0_MASK,
  138. MP_CPUSYS_TOP_BUS_PLL_DIV_DCM_REG0_OFF);
  139. }
  140. }
  141. #define MP_CPUSYS_TOP_CORE_STALL_DCM_REG0_MASK (BIT(0))
  142. #define MP_CPUSYS_TOP_CORE_STALL_DCM_REG0_ON (BIT(0))
  143. #define MP_CPUSYS_TOP_CORE_STALL_DCM_REG0_OFF ((0x0 << 0))
  144. bool dcm_mp_cpusys_top_core_stall_dcm_is_on(void)
  145. {
  146. bool ret = true;
  147. ret &= ((mmio_read_32(MP_CPUSYS_TOP_MP0_DCM_CFG7) &
  148. MP_CPUSYS_TOP_CORE_STALL_DCM_REG0_MASK) ==
  149. (unsigned int) MP_CPUSYS_TOP_CORE_STALL_DCM_REG0_ON);
  150. return ret;
  151. }
  152. void dcm_mp_cpusys_top_core_stall_dcm(bool on)
  153. {
  154. if (on) {
  155. /* TINFO = "Turn ON DCM 'mp_cpusys_top_core_stall_dcm'" */
  156. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP0_DCM_CFG7,
  157. MP_CPUSYS_TOP_CORE_STALL_DCM_REG0_MASK,
  158. MP_CPUSYS_TOP_CORE_STALL_DCM_REG0_ON);
  159. } else {
  160. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_core_stall_dcm'" */
  161. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP0_DCM_CFG7,
  162. MP_CPUSYS_TOP_CORE_STALL_DCM_REG0_MASK,
  163. MP_CPUSYS_TOP_CORE_STALL_DCM_REG0_OFF);
  164. }
  165. }
  166. #define MP_CPUSYS_TOP_CPUBIU_DBG_CG_REG0_MASK (BIT(0))
  167. #define MP_CPUSYS_TOP_CPUBIU_DBG_CG_REG0_ON ((0x0 << 0))
  168. #define MP_CPUSYS_TOP_CPUBIU_DBG_CG_REG0_OFF (BIT(0))
  169. bool dcm_mp_cpusys_top_cpubiu_dbg_cg_is_on(void)
  170. {
  171. bool ret = true;
  172. ret &= ((mmio_read_32(MP_CPUSYS_TOP_MCSI_CFG2) &
  173. MP_CPUSYS_TOP_CPUBIU_DBG_CG_REG0_MASK) ==
  174. (unsigned int) MP_CPUSYS_TOP_CPUBIU_DBG_CG_REG0_ON);
  175. return ret;
  176. }
  177. void dcm_mp_cpusys_top_cpubiu_dbg_cg(bool on)
  178. {
  179. if (on) {
  180. /* TINFO = "Turn ON DCM 'mp_cpusys_top_cpubiu_dbg_cg'" */
  181. mmio_clrsetbits_32(MP_CPUSYS_TOP_MCSI_CFG2,
  182. MP_CPUSYS_TOP_CPUBIU_DBG_CG_REG0_MASK,
  183. MP_CPUSYS_TOP_CPUBIU_DBG_CG_REG0_ON);
  184. } else {
  185. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_cpubiu_dbg_cg'" */
  186. mmio_clrsetbits_32(MP_CPUSYS_TOP_MCSI_CFG2,
  187. MP_CPUSYS_TOP_CPUBIU_DBG_CG_REG0_MASK,
  188. MP_CPUSYS_TOP_CPUBIU_DBG_CG_REG0_OFF);
  189. }
  190. }
  191. #define MP_CPUSYS_TOP_CPUBIU_DCM_REG0_MASK ((0xffff << 0))
  192. #define MP_CPUSYS_TOP_CPUBIU_DCM_REG0_ON ((0xffff << 0))
  193. #define MP_CPUSYS_TOP_CPUBIU_DCM_REG0_OFF ((0x0 << 0))
  194. bool dcm_mp_cpusys_top_cpubiu_dcm_is_on(void)
  195. {
  196. bool ret = true;
  197. ret &= ((mmio_read_32(MP_CPUSYS_TOP_MCSIC_DCM0) &
  198. MP_CPUSYS_TOP_CPUBIU_DCM_REG0_MASK) ==
  199. (unsigned int) MP_CPUSYS_TOP_CPUBIU_DCM_REG0_ON);
  200. return ret;
  201. }
  202. void dcm_mp_cpusys_top_cpubiu_dcm(bool on)
  203. {
  204. if (on) {
  205. /* TINFO = "Turn ON DCM 'mp_cpusys_top_cpubiu_dcm'" */
  206. mmio_clrsetbits_32(MP_CPUSYS_TOP_MCSIC_DCM0,
  207. MP_CPUSYS_TOP_CPUBIU_DCM_REG0_MASK,
  208. MP_CPUSYS_TOP_CPUBIU_DCM_REG0_ON);
  209. } else {
  210. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_cpubiu_dcm'" */
  211. mmio_clrsetbits_32(MP_CPUSYS_TOP_MCSIC_DCM0,
  212. MP_CPUSYS_TOP_CPUBIU_DCM_REG0_MASK,
  213. MP_CPUSYS_TOP_CPUBIU_DCM_REG0_OFF);
  214. }
  215. }
  216. #define MP_CPUSYS_TOP_CPU_PLL_DIV_0_DCM_REG0_MASK (BIT(11) | \
  217. BIT(24) | \
  218. BIT(25))
  219. #define MP_CPUSYS_TOP_CPU_PLL_DIV_0_DCM_REG0_ON (BIT(11) | \
  220. BIT(24) | \
  221. BIT(25))
  222. #define MP_CPUSYS_TOP_CPU_PLL_DIV_0_DCM_REG0_OFF ((0x0 << 11) | \
  223. (0x0 << 24) | \
  224. (0x0 << 25))
  225. bool dcm_mp_cpusys_top_cpu_pll_div_0_dcm_is_on(void)
  226. {
  227. bool ret = true;
  228. ret &= ((mmio_read_32(MP_CPUSYS_TOP_CPU_PLLDIV_CFG0) &
  229. MP_CPUSYS_TOP_CPU_PLL_DIV_0_DCM_REG0_MASK) ==
  230. (unsigned int) MP_CPUSYS_TOP_CPU_PLL_DIV_0_DCM_REG0_ON);
  231. return ret;
  232. }
  233. void dcm_mp_cpusys_top_cpu_pll_div_0_dcm(bool on)
  234. {
  235. if (on) {
  236. /* TINFO = "Turn ON DCM 'mp_cpusys_top_cpu_pll_div_0_dcm'" */
  237. mmio_clrsetbits_32(MP_CPUSYS_TOP_CPU_PLLDIV_CFG0,
  238. MP_CPUSYS_TOP_CPU_PLL_DIV_0_DCM_REG0_MASK,
  239. MP_CPUSYS_TOP_CPU_PLL_DIV_0_DCM_REG0_ON);
  240. } else {
  241. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_cpu_pll_div_0_dcm'" */
  242. mmio_clrsetbits_32(MP_CPUSYS_TOP_CPU_PLLDIV_CFG0,
  243. MP_CPUSYS_TOP_CPU_PLL_DIV_0_DCM_REG0_MASK,
  244. MP_CPUSYS_TOP_CPU_PLL_DIV_0_DCM_REG0_OFF);
  245. }
  246. }
  247. #define MP_CPUSYS_TOP_CPU_PLL_DIV_1_DCM_REG0_MASK (BIT(11) | \
  248. BIT(24) | \
  249. BIT(25))
  250. #define MP_CPUSYS_TOP_CPU_PLL_DIV_1_DCM_REG0_ON (BIT(11) | \
  251. BIT(24) | \
  252. BIT(25))
  253. #define MP_CPUSYS_TOP_CPU_PLL_DIV_1_DCM_REG0_OFF ((0x0 << 11) | \
  254. (0x0 << 24) | \
  255. (0x0 << 25))
  256. bool dcm_mp_cpusys_top_cpu_pll_div_1_dcm_is_on(void)
  257. {
  258. bool ret = true;
  259. ret &= ((mmio_read_32(MP_CPUSYS_TOP_CPU_PLLDIV_CFG1) &
  260. MP_CPUSYS_TOP_CPU_PLL_DIV_1_DCM_REG0_MASK) ==
  261. (unsigned int) MP_CPUSYS_TOP_CPU_PLL_DIV_1_DCM_REG0_ON);
  262. return ret;
  263. }
  264. void dcm_mp_cpusys_top_cpu_pll_div_1_dcm(bool on)
  265. {
  266. if (on) {
  267. /* TINFO = "Turn ON DCM 'mp_cpusys_top_cpu_pll_div_1_dcm'" */
  268. mmio_clrsetbits_32(MP_CPUSYS_TOP_CPU_PLLDIV_CFG1,
  269. MP_CPUSYS_TOP_CPU_PLL_DIV_1_DCM_REG0_MASK,
  270. MP_CPUSYS_TOP_CPU_PLL_DIV_1_DCM_REG0_ON);
  271. } else {
  272. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_cpu_pll_div_1_dcm'" */
  273. mmio_clrsetbits_32(MP_CPUSYS_TOP_CPU_PLLDIV_CFG1,
  274. MP_CPUSYS_TOP_CPU_PLL_DIV_1_DCM_REG0_MASK,
  275. MP_CPUSYS_TOP_CPU_PLL_DIV_1_DCM_REG0_OFF);
  276. }
  277. }
  278. #define MP_CPUSYS_TOP_FCM_STALL_DCM_REG0_MASK (BIT(4))
  279. #define MP_CPUSYS_TOP_FCM_STALL_DCM_REG0_ON (BIT(4))
  280. #define MP_CPUSYS_TOP_FCM_STALL_DCM_REG0_OFF ((0x0 << 4))
  281. bool dcm_mp_cpusys_top_fcm_stall_dcm_is_on(void)
  282. {
  283. bool ret = true;
  284. ret &= ((mmio_read_32(MP_CPUSYS_TOP_MP0_DCM_CFG7) &
  285. MP_CPUSYS_TOP_FCM_STALL_DCM_REG0_MASK) ==
  286. (unsigned int) MP_CPUSYS_TOP_FCM_STALL_DCM_REG0_ON);
  287. return ret;
  288. }
  289. void dcm_mp_cpusys_top_fcm_stall_dcm(bool on)
  290. {
  291. if (on) {
  292. /* TINFO = "Turn ON DCM 'mp_cpusys_top_fcm_stall_dcm'" */
  293. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP0_DCM_CFG7,
  294. MP_CPUSYS_TOP_FCM_STALL_DCM_REG0_MASK,
  295. MP_CPUSYS_TOP_FCM_STALL_DCM_REG0_ON);
  296. } else {
  297. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_fcm_stall_dcm'" */
  298. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP0_DCM_CFG7,
  299. MP_CPUSYS_TOP_FCM_STALL_DCM_REG0_MASK,
  300. MP_CPUSYS_TOP_FCM_STALL_DCM_REG0_OFF);
  301. }
  302. }
  303. #define MP_CPUSYS_TOP_LAST_COR_IDLE_DCM_REG0_MASK (BIT(31))
  304. #define MP_CPUSYS_TOP_LAST_COR_IDLE_DCM_REG0_ON (BIT(31))
  305. #define MP_CPUSYS_TOP_LAST_COR_IDLE_DCM_REG0_OFF ((0x0 << 31))
  306. bool dcm_mp_cpusys_top_last_cor_idle_dcm_is_on(void)
  307. {
  308. bool ret = true;
  309. ret &= ((mmio_read_32(MP_CPUSYS_TOP_BUS_PLLDIV_CFG) &
  310. MP_CPUSYS_TOP_LAST_COR_IDLE_DCM_REG0_MASK) ==
  311. (unsigned int) MP_CPUSYS_TOP_LAST_COR_IDLE_DCM_REG0_ON);
  312. return ret;
  313. }
  314. void dcm_mp_cpusys_top_last_cor_idle_dcm(bool on)
  315. {
  316. if (on) {
  317. /* TINFO = "Turn ON DCM 'mp_cpusys_top_last_cor_idle_dcm'" */
  318. mmio_clrsetbits_32(MP_CPUSYS_TOP_BUS_PLLDIV_CFG,
  319. MP_CPUSYS_TOP_LAST_COR_IDLE_DCM_REG0_MASK,
  320. MP_CPUSYS_TOP_LAST_COR_IDLE_DCM_REG0_ON);
  321. } else {
  322. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_last_cor_idle_dcm'" */
  323. mmio_clrsetbits_32(MP_CPUSYS_TOP_BUS_PLLDIV_CFG,
  324. MP_CPUSYS_TOP_LAST_COR_IDLE_DCM_REG0_MASK,
  325. MP_CPUSYS_TOP_LAST_COR_IDLE_DCM_REG0_OFF);
  326. }
  327. }
  328. #define MP_CPUSYS_TOP_MISC_DCM_REG0_MASK (BIT(0) | \
  329. BIT(1) | \
  330. BIT(2) | \
  331. BIT(3) | \
  332. BIT(4))
  333. #define MP_CPUSYS_TOP_MISC_DCM_REG0_ON (BIT(0) | \
  334. BIT(1) | \
  335. BIT(2) | \
  336. BIT(3) | \
  337. BIT(4))
  338. #define MP_CPUSYS_TOP_MISC_DCM_REG0_OFF ((0x0 << 0) | \
  339. (0x0 << 1) | \
  340. (0x0 << 2) | \
  341. (0x0 << 3) | \
  342. (0x0 << 4))
  343. bool dcm_mp_cpusys_top_misc_dcm_is_on(void)
  344. {
  345. bool ret = true;
  346. ret &= ((mmio_read_32(MP_CPUSYS_TOP_MP_MISC_DCM_CFG0) &
  347. MP_CPUSYS_TOP_MISC_DCM_REG0_MASK) ==
  348. (unsigned int) MP_CPUSYS_TOP_MISC_DCM_REG0_ON);
  349. return ret;
  350. }
  351. void dcm_mp_cpusys_top_misc_dcm(bool on)
  352. {
  353. if (on) {
  354. /* TINFO = "Turn ON DCM 'mp_cpusys_top_misc_dcm'" */
  355. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP_MISC_DCM_CFG0,
  356. MP_CPUSYS_TOP_MISC_DCM_REG0_MASK,
  357. MP_CPUSYS_TOP_MISC_DCM_REG0_ON);
  358. } else {
  359. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_misc_dcm'" */
  360. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP_MISC_DCM_CFG0,
  361. MP_CPUSYS_TOP_MISC_DCM_REG0_MASK,
  362. MP_CPUSYS_TOP_MISC_DCM_REG0_OFF);
  363. }
  364. }
  365. #define MP_CPUSYS_TOP_MP0_QDCM_REG0_MASK (BIT(0) | \
  366. BIT(1) | \
  367. BIT(2) | \
  368. BIT(3))
  369. #define MP_CPUSYS_TOP_MP0_QDCM_REG0_ON (BIT(0) | \
  370. BIT(1) | \
  371. BIT(2) | \
  372. BIT(3))
  373. #define MP_CPUSYS_TOP_MP0_QDCM_REG0_OFF ((0x0 << 0) | \
  374. (0x0 << 1) | \
  375. (0x0 << 2) | \
  376. (0x0 << 3))
  377. bool dcm_mp_cpusys_top_mp0_qdcm_is_on(void)
  378. {
  379. bool ret = true;
  380. ret &= ((mmio_read_32(MP_CPUSYS_TOP_MP0_DCM_CFG0) &
  381. MP_CPUSYS_TOP_MP0_QDCM_REG0_MASK) ==
  382. (unsigned int) MP_CPUSYS_TOP_MP0_QDCM_REG0_ON);
  383. return ret;
  384. }
  385. void dcm_mp_cpusys_top_mp0_qdcm(bool on)
  386. {
  387. if (on) {
  388. /* TINFO = "Turn ON DCM 'mp_cpusys_top_mp0_qdcm'" */
  389. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP0_DCM_CFG0,
  390. MP_CPUSYS_TOP_MP0_QDCM_REG0_MASK,
  391. MP_CPUSYS_TOP_MP0_QDCM_REG0_ON);
  392. } else {
  393. /* TINFO = "Turn OFF DCM 'mp_cpusys_top_mp0_qdcm'" */
  394. mmio_clrsetbits_32(MP_CPUSYS_TOP_MP0_DCM_CFG0,
  395. MP_CPUSYS_TOP_MP0_QDCM_REG0_MASK,
  396. MP_CPUSYS_TOP_MP0_QDCM_REG0_OFF);
  397. }
  398. }
  399. #define CPCCFG_REG_EMI_WFIFO_REG0_MASK (BIT(0) | BIT(2))
  400. #define CPCCFG_REG_EMI_WFIFO_REG0_ON (BIT(0) | BIT(2))
  401. #define CPCCFG_REG_EMI_WFIFO_REG0_OFF ((0x0 << 0) | (0x0 << 2))
  402. bool dcm_cpccfg_reg_emi_wfifo_is_on(void)
  403. {
  404. bool ret = true;
  405. ret &= ((mmio_read_32(CPCCFG_REG_EMI_WFIFO) &
  406. CPCCFG_REG_EMI_WFIFO_REG0_MASK) ==
  407. (unsigned int) CPCCFG_REG_EMI_WFIFO_REG0_ON);
  408. return ret;
  409. }
  410. void dcm_cpccfg_reg_emi_wfifo(bool on)
  411. {
  412. if (on) {
  413. /* TINFO = "Turn ON DCM 'cpccfg_reg_emi_wfifo'" */
  414. mmio_clrsetbits_32(CPCCFG_REG_EMI_WFIFO,
  415. CPCCFG_REG_EMI_WFIFO_REG0_MASK,
  416. CPCCFG_REG_EMI_WFIFO_REG0_ON);
  417. } else {
  418. /* TINFO = "Turn OFF DCM 'cpccfg_reg_emi_wfifo'" */
  419. mmio_clrsetbits_32(CPCCFG_REG_EMI_WFIFO,
  420. CPCCFG_REG_EMI_WFIFO_REG0_MASK,
  421. CPCCFG_REG_EMI_WFIFO_REG0_OFF);
  422. }
  423. }