Debian Codegraph @

src/soc/mediatek/mt8189/mtcmos.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2
3 /*
4 * This file is created based on MT8189 Functional Specification
5 * Chapter number: 8.1
6 */
7
8 #include <console/console.h>
9 #include <soc/mtcmos.h>
10 #include <soc/spm.h>
11 #include <soc/spm_mtcmos.h>
12
13 static const struct bus_protect bp_ufs[] = {
14 {
15 .clr_addr = &mtk_vlpcfg->bus_vlp_topaxi_protecten_clr,
16 .set_addr = &mtk_vlpcfg->bus_vlp_topaxi_protecten_set,
17 .rdy_addr = &mtk_vlpcfg->bus_vlp_topaxi_protecten_sta1,
18 .mask = BIT(6),
19 },
20 {
21 .clr_addr = &mtk_infracfg_ao->perisys_protect.clr,
22 .set_addr = &mtk_infracfg_ao->perisys_protect.set,
23 .rdy_addr = &mtk_infracfg_ao->perisys_protect.ready,
24 .mask = BIT(4),
25 },
26 {
27 .clr_addr = &mtk_vlpcfg->bus_vlp_topaxi_protecten_clr,
28 .set_addr = &mtk_vlpcfg->bus_vlp_topaxi_protecten_set,
29 .rdy_addr = &mtk_vlpcfg->bus_vlp_topaxi_protecten_sta1,
30 .mask = BIT(5),
31 },
32 };
33
34 static const struct bus_protect bp_mminfra[] = {
35 {
36 .clr_addr = &mtk_infracfg_ao->emisys_protect.clr,
37 .mask = BIT(20) | BIT(21),
38 },
39 {
40 .clr_addr = &mtk_infracfg_ao->infrasys_protect[0].clr,
41 .mask = BIT(16),
42 },
43 {
44 .clr_addr = &mtk_infracfg_ao->mmsys_protect[1].clr,
45 .mask = BIT(0) | BIT(7) | BIT(8) | BIT(9) | BIT(10) |
46 BIT(11) | BIT(12) | BIT(13) | BIT(14) | BIT(15),
47 },
48 {
49 .clr_addr = &mtk_infracfg_ao->infrasys_protect[1].clr,
50 .mask = BIT(11),
51 },
52 {
53 .clr_addr = &mtk_infracfg_ao->mmsys_protect[1].clr,
54 .mask = BIT(1) | BIT(2) | BIT(3),
55 },
56 };
57
58 static const struct bus_protect bp_ssusb[] = {
59 {
60 .clr_addr = &mtk_infracfg_ao->perisys_protect.clr,
61 .mask = BIT(7),
62 },
63 };
64
65 static const struct power_domain_data pd_plat[] = {
66 {
67 /* ufs0 */
68 .pwr_con = &mtk_spm->ufs0_pwr_con,
69 .pwr_sta_mask = BIT(4),
70 .sram_pdn_mask = BIT(8),
71 .sram_ack_mask = BIT(12),
72 .bp_steps = ARRAY_SIZE(bp_ufs),
73 .bp_table = bp_ufs,
74 },
75 {
76 /* ufs0_phy */
77 .pwr_con = &mtk_spm->ufs0_phy_pwr_con,
78 .pwr_sta_mask = BIT(5),
79 },
80 {
81 /* mm_infra */
82 .pwr_con = &mtk_spm->mm_infra_pwr_con,
83 .pwr_sta_mask = BIT(30),
84 .sram_pdn_mask = BIT(8),
85 .sram_ack_mask = BIT(12),
86 .bp_steps = ARRAY_SIZE(bp_mminfra),
87 .bp_table = bp_mminfra,
88 },
89 {
90 /* ssusb */
91 .pwr_con = &mtk_spm->ssusb_pwr_con,
92 .pwr_status = &mtk_spm->pwr_status_msb,
93 .pwr_status_2nd = &mtk_spm->pwr_status_msb_2nd,
94 .pwr_sta_mask = BIT(10),
95 .sram_pdn_mask = BIT(8),
96 .sram_ack_mask = BIT(12),
97 .bp_steps = ARRAY_SIZE(bp_ssusb),
98 .bp_table = bp_ssusb,
99 },
100 };
101
102 void spm_power_on(void)
103 {
104 write32(&mtk_spm->poweron_config_set, SPM_REGWR_CFG_KEY | (0x1 << 0));
105 }
106
107 void mtcmos_init(void)
108 {
109 int i;
110
111 for (i = 0; i < ARRAY_SIZE(pd_plat); i++)
112 mtcmos_power_on(&pd_plat[i]);
113 }
114
115 void mtcmos_ufs_power_off(void)
116 {
117 /* ufs0_phy */
118 mtcmos_power_off(&pd_plat[1]);
119 /* ufs0 */
120 mtcmos_power_off(&pd_plat[0]);
121 }
122
123 void mtcmos_protect_audio_bus(void)
124 {
125 write32(&mtk_infracfg_ao->perisys_protect.clr, BIT(6));
126
127 /* AUDIO CG Clear */
128 clrbits32(&mtk_afe->audio_audio_top[0], 0x03364F80);
129 clrbits32(&mtk_afe->audio_audio_top[1], 0x00F000FF);
130 clrbits32(&mtk_afe->audio_audio_top[2], 0x01323000);
131 clrbits32(&mtk_afe->audio_audio_top[3], 0x03F00000);
132 clrbits32(&mtk_afe->audio_audio_top[4], 0x0000301F);
133 }
134
135 void mtcmos_protect_display_bus(void)
136 {
137 write32(&mtk_infracfg_ao->mmsys_protect[0].clr, BIT(1) | BIT(0));
138
139 /* MMSYS_CONFIG CG Clear */
140 write32(&mtk_mmsys_config->mmsys_config_mmsys_cg_0_clr, 0xFF7FFFFF);
141 write32(&mtk_mmsys_config->mmsys_config_mmsys_cg_1_clr, 0x0000007B);
142 }