blob: f6ee122bf96a25fcb71866622c6b3732e6f013ba [file] [log] [blame]
Angel Ponse67ab182020-04-04 18:51:11 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Yidi Lin3d7b6062015-07-31 17:10:40 +08002
Ting Shendff29e02019-01-28 18:15:00 +08003#include <bootmem.h>
Yidi Lin3d7b6062015-07-31 17:10:40 +08004#include <device/device.h>
Yidi Lin28188e32022-12-05 16:24:57 +08005#include <program_loading.h>
Yidi Lin3d7b6062015-07-31 17:10:40 +08006#include <symbols.h>
Yidi Linc6d7dcc2016-02-04 17:26:48 +08007#include <soc/emi.h>
Yidi Lin3d7b6062015-07-31 17:10:40 +08008
Yidi Lin28188e32022-12-05 16:24:57 +08009int payload_arch_usable_ram_quirk(uint64_t start, uint64_t size)
10{
11 if (size > REGION_SIZE(sram))
12 return 0;
13
14 if (start >= (uintptr_t)_sram && (start + size) <= (uintptr_t)_esram) {
15 printk(BIOS_DEBUG, "MT8173 uses SRAM for loading BL31.\n");
16 return 1;
17 }
18
19 return 0;
20}
21
Ting Shendff29e02019-01-28 18:15:00 +080022void bootmem_platform_add_ranges(void)
23{
24 bootmem_add_range(0x101000, 124 * KiB, BM_MEM_BL31);
25}
26
Elyes HAOUASb4426692018-05-25 10:09:55 +020027static void soc_read_resources(struct device *dev)
Yidi Lin3d7b6062015-07-31 17:10:40 +080028{
Kyösti Mälkki85eb34e2022-06-20 14:13:36 +030029 ram_range(dev, 0, (uintptr_t)_dram, sdram_size());
Yidi Lin3d7b6062015-07-31 17:10:40 +080030}
31
Elyes HAOUASb4426692018-05-25 10:09:55 +020032static void soc_init(struct device *dev)
Yidi Lin3d7b6062015-07-31 17:10:40 +080033{
34}
35
36static struct device_operations soc_ops = {
37 .read_resources = soc_read_resources,
Yu-Ping Wu39e6f852022-03-14 16:53:59 +080038 .set_resources = noop_set_resources,
Yidi Lin3d7b6062015-07-31 17:10:40 +080039 .init = soc_init,
40};
41
Elyes HAOUASb4426692018-05-25 10:09:55 +020042static void enable_soc_dev(struct device *dev)
Yidi Lin3d7b6062015-07-31 17:10:40 +080043{
44 dev->ops = &soc_ops;
45}
46
47struct chip_operations soc_mediatek_mt8173_ops = {
Nicholas Sudsgaardbfb11be2024-01-30 09:53:46 +090048 .name = "SOC Mediatek MT8173",
Yidi Lin47a9af42016-03-28 15:16:45 +080049 .enable_dev = enable_soc_dev,
Yidi Lin3d7b6062015-07-31 17:10:40 +080050};