Debian Codegraph @

src/soc/mediatek/mt8188/soc.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2
3 #include <bootmem.h>
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <soc/cpu_input_gating.h>
7 #include <soc/devapc.h>
8 #include <soc/dfd.h>
9 #include <soc/dpm_v1.h>
10 #include <soc/emi.h>
11 #include <soc/mcupm.h>
12 #include <soc/mmu_operations.h>
13 #include <soc/spm.h>
14 #include <soc/sspm.h>
15 #include <symbols.h>
16
17 #define OPTEE_ADDRESS 0x43000000
18 #define OPTEE_SIZE (70 * MiB)
19
20 void bootmem_platform_add_ranges(void)
21 {
22 if (CONFIG(MTK_DFD))
23 bootmem_add_range(DFD_DUMP_ADDRESS, DFD_DUMP_SIZE, BM_MEM_RESERVED);
24 if (CONFIG(ARM64_BL31_OPTEE_WITH_SMC))
25 bootmem_add_range(OPTEE_ADDRESS, OPTEE_SIZE, BM_MEM_RESERVED);
26 }
27
28 static void soc_read_resources(struct device *dev)
29 {
30 ram_range(dev, 0, (uintptr_t)_dram, sdram_size());
31 }
32
33 static void soc_init(struct device *dev)
34 {
35 mtk_mmu_disable_l2c_sram();
36
37 disable_cpu_input_gating();
38
39 dapc_init();
40 mcupm_init();
41 sspm_init();
42
43 if (dpm_init())
44 printk(BIOS_ERR, "dpm init failed, DVFS may not work\n");
45
46 /*
47 * For MT8188, SPM will handshake with DPM to do initialization, so
48 * this must run after dpm_init().
49 */
50 if (spm_init())
51 printk(BIOS_ERR, "spm init failed, system suspend may not work\n");
52
53 if (CONFIG(MTK_DFD))
54 dfd_init();
55 }
56
57 static struct device_operations soc_ops = {
58 .read_resources = soc_read_resources,
59 .set_resources = noop_set_resources,
60 .init = soc_init,
61 };
62
63 static void enable_soc_dev(struct device *dev)
64 {
65 dev->ops = &soc_ops;
66 }
67
68 struct chip_operations soc_mediatek_mt8188_ops = {
69 .name = "SOC Mediatek MT8188",
70 .enable_dev = enable_soc_dev,
71 };