xref: /rk3399_ARM-atf/plat/mediatek/mt8196/drivers/dcm/mtk_dcm.c (revision b47dddd061e92054c3b2096fc8aa9688bfef68d6)
1 /*
2  * Copyright (c) 2025, MediaTek Inc. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <common/debug.h>
8 #include <lib/mmio.h>
9 #include <lib/mtk_init/mtk_init.h>
10 #include <mtk_dcm_utils.h>
11 
12 static void dcm_infra(bool on)
13 {
14 	dcm_bcrm_apinfra_io_ctrl_ao_infra_bus_dcm(on);
15 	dcm_bcrm_apinfra_io_noc_ao_infra_bus_dcm(on);
16 	dcm_bcrm_apinfra_mem_ctrl_ao_infra_bus_dcm(on);
17 	dcm_bcrm_apinfra_mem_intf_noc_ao_infra_bus_dcm(on);
18 }
19 
20 static void dcm_mcusys(bool on)
21 {
22 	dcm_mcusys_par_wrap_mcu_misc_dcm(on);
23 }
24 
25 static void dcm_mcusys_acp(bool on)
26 {
27 	dcm_mcusys_par_wrap_mcu_acp_dcm(on);
28 }
29 
30 static void dcm_mcusys_adb(bool on)
31 {
32 	dcm_mcusys_par_wrap_mcu_adb_dcm(on);
33 }
34 
35 static void dcm_mcusys_apb(bool on)
36 {
37 	dcm_mcusys_par_wrap_mcu_apb_dcm(on);
38 }
39 
40 static void dcm_mcusys_bus(bool on)
41 {
42 	dcm_mcusys_par_wrap_mcu_bus_qdcm(on);
43 }
44 
45 static void dcm_mcusys_cbip(bool on)
46 {
47 	dcm_mcusys_par_wrap_mcu_cbip_dcm(on);
48 }
49 
50 static void dcm_mcusys_chi_mon(bool on)
51 {
52 	dcm_mcusys_par_wrap_mcu_chi_mon_dcm(on);
53 }
54 
55 static void dcm_mcusys_core(bool on)
56 {
57 	dcm_mcusys_par_wrap_mcu_core_qdcm(on);
58 }
59 
60 static void dcm_mcusys_dsu_acp(bool on)
61 {
62 	dcm_mcusys_par_wrap_mcu_dsu_acp_dcm(on);
63 }
64 
65 static void dcm_mcusys_ebg(bool on)
66 {
67 	dcm_mcusys_par_wrap_mcu_ebg_dcm(on);
68 }
69 
70 static void dcm_mcusys_gic_spi(bool on)
71 {
72 	dcm_mcusys_par_wrap_mcu_gic_spi_dcm(on);
73 }
74 
75 static void dcm_mcusys_io(bool on)
76 {
77 	dcm_mcusys_par_wrap_mcu_io_dcm(on);
78 }
79 
80 static void dcm_mcusys_l3c(bool on)
81 {
82 	dcm_mcusys_par_wrap_mcu_l3c_dcm(on);
83 }
84 
85 static void dcm_mcusys_stall(bool on)
86 {
87 	dcm_mcusys_par_wrap_mcu_stalldcm(on);
88 }
89 
90 static void dcm_vlp(bool on)
91 {
92 	dcm_vlp_ao_bcrm_vlp_bus_dcm(on);
93 }
94 
95 int mtk_dcm_init(void)
96 {
97 	dcm_infra(true);
98 	dcm_mcusys(true);
99 	dcm_mcusys_acp(true);
100 	dcm_mcusys_adb(true);
101 	dcm_mcusys_apb(true);
102 	dcm_mcusys_bus(true);
103 	dcm_mcusys_cbip(true);
104 	dcm_mcusys_chi_mon(true);
105 	dcm_mcusys_core(true);
106 	dcm_mcusys_dsu_acp(true);
107 	dcm_mcusys_ebg(true);
108 	dcm_mcusys_gic_spi(true);
109 	dcm_mcusys_io(true);
110 	dcm_mcusys_l3c(true);
111 	dcm_mcusys_stall(true);
112 	dcm_vlp(true);
113 
114 	return 0;
115 }
116 
117 MTK_PLAT_SETUP_0_INIT(mtk_dcm_init);
118