blob: d0a29c578c3b7a8f40167f7da80746872e8a95a1 [file] [log] [blame]
Macpaul Lin577766e2022-08-11 18:46:06 +08001/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
Rex-BC Chen3f83c6f2022-05-24 19:45:59 +08002
Rex-BC Chenc3d2e9c2022-08-04 17:11:22 +08003#include <bootmem.h>
Xi Chenaf4bad12022-08-18 11:27:18 +08004#include <console/console.h>
Rex-BC Chen3f83c6f2022-05-24 19:45:59 +08005#include <device/device.h>
Liju-Clr Chen5ab991d2022-11-01 10:35:33 +08006#include <soc/cpu_input_gating.h>
Nina Wuc0797f52022-08-18 11:13:31 +08007#include <soc/devapc.h>
Rex-BC Chenc3d2e9c2022-08-04 17:11:22 +08008#include <soc/dfd.h>
Xi Chenaf4bad12022-08-18 11:27:18 +08009#include <soc/dpm.h>
Rex-BC Chen3f83c6f2022-05-24 19:45:59 +080010#include <soc/emi.h>
Rex-BC Chen0c7a0f92022-07-22 11:09:55 +080011#include <soc/mcupm.h>
Rex-BC Chen29f18662022-06-15 11:49:16 +080012#include <soc/mmu_operations.h>
Rex-BC Chenc23235e2022-08-10 18:23:01 +080013#include <soc/spm.h>
Rex-BC Chen202f60b2022-07-22 13:41:45 +080014#include <soc/sspm.h>
Rex-BC Chen3f83c6f2022-05-24 19:45:59 +080015#include <symbols.h>
16
kiwi liu4bd12362023-11-01 15:07:33 +080017#define OPTEE_ADDRESS 0x43000000
18#define OPTEE_SIZE (80 * MiB)
19
Rex-BC Chenc3d2e9c2022-08-04 17:11:22 +080020void bootmem_platform_add_ranges(void)
21{
22 if (CONFIG(MTK_DFD))
23 bootmem_add_range(DFD_DUMP_ADDRESS, DFD_DUMP_SIZE, BM_MEM_RESERVED);
kiwi liu4bd12362023-11-01 15:07:33 +080024 bootmem_add_range(OPTEE_ADDRESS, OPTEE_SIZE, BM_MEM_RESERVED);
Rex-BC Chenc3d2e9c2022-08-04 17:11:22 +080025}
26
Rex-BC Chen3f83c6f2022-05-24 19:45:59 +080027static void soc_read_resources(struct device *dev)
28{
29 ram_range(dev, 0, (uintptr_t)_dram, sdram_size());
30}
31
32static void soc_init(struct device *dev)
33{
Rex-BC Chen29f18662022-06-15 11:49:16 +080034 mtk_mmu_disable_l2c_sram();
Liju-Clr Chen5ab991d2022-11-01 10:35:33 +080035
36 disable_cpu_input_gating();
37
Nina Wuc0797f52022-08-18 11:13:31 +080038 dapc_init();
Rex-BC Chen0c7a0f92022-07-22 11:09:55 +080039 mcupm_init();
Rex-BC Chen202f60b2022-07-22 13:41:45 +080040 sspm_init();
Rex-BC Chenc3d2e9c2022-08-04 17:11:22 +080041
Xi Chenaf4bad12022-08-18 11:27:18 +080042 if (dpm_init())
43 printk(BIOS_ERR, "dpm init failed, DVFS may not work\n");
44
Rex-BC Chenc23235e2022-08-10 18:23:01 +080045 /*
46 * For MT8188, SPM will handshake with DPM to do initialization, so
47 * this must run after dpm_init().
48 */
49 if (spm_init())
50 printk(BIOS_ERR, "spm init failed, system suspend may not work\n");
51
Rex-BC Chenc3d2e9c2022-08-04 17:11:22 +080052 if (CONFIG(MTK_DFD))
53 dfd_init();
Rex-BC Chen3f83c6f2022-05-24 19:45:59 +080054}
55
56static struct device_operations soc_ops = {
57 .read_resources = soc_read_resources,
58 .set_resources = noop_set_resources,
59 .init = soc_init,
60};
61
62static void enable_soc_dev(struct device *dev)
63{
64 dev->ops = &soc_ops;
65}
66
67struct chip_operations soc_mediatek_mt8188_ops = {
68 CHIP_NAME("SOC Mediatek MT8188")
69 .enable_dev = enable_soc_dev,
70};