mtk_dcm_utils.c 14 KB

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