| 1 |
|
| 2 |
|
| 3 |
#include <bootmem.h> |
| 4 |
#include <device/device.h> |
| 5 |
#include <device/pci.h> |
| 6 |
#include <soc/dcc.h> |
| 7 |
#include <soc/dramc_info.h> |
| 8 |
#include <soc/emi.h> |
| 9 |
#include <soc/gpueb.h> |
| 10 |
#include <soc/mcupm.h> |
| 11 |
#include <soc/mmu_operations.h> |
| 12 |
#include <soc/mt6685.h> |
| 13 |
#include <soc/mtk_fsp.h> |
| 14 |
#include <soc/pcie.h> |
| 15 |
#include <soc/pi_image.h> |
| 16 |
#include <soc/sspm.h> |
| 17 |
#include <soc/storage.h> |
| 18 |
#include <soc/symbols.h> |
| 19 |
#include <symbols.h> |
| 20 |
|
| 21 |
void bootmem_platform_add_ranges(void) |
| 22 |
{ |
| 23 |
if (CONFIG(ARM64_BL31_OPTEE_WITH_SMC)) |
| 24 |
bootmem_add_range((uint64_t)_resv_mem_optee, |
| 25 |
REGION_SIZE(resv_mem_optee), BM_MEM_RESERVED); |
| 26 |
|
| 27 |
reserve_buffer_for_dramc(); |
| 28 |
|
| 29 |
bootmem_add_range((uint64_t)_resv_mem_gpu, REGION_SIZE(resv_mem_gpu), BM_MEM_RESERVED); |
| 30 |
bootmem_add_range((uint64_t)_resv_mem_gpueb, |
| 31 |
REGION_SIZE(resv_mem_gpueb), BM_MEM_RESERVED); |
| 32 |
} |
| 33 |
|
| 34 |
static void soc_read_resources(struct device *dev) |
| 35 |
{ |
| 36 |
ram_range(dev, 0, (uintptr_t)_dram, sdram_size()); |
| 37 |
} |
| 38 |
|
| 39 |
static void soc_init(struct device *dev) |
| 40 |
{ |
| 41 |
uint32_t storage_type = mainboard_get_storage_type(); |
| 42 |
|
| 43 |
dcc_init(); |
| 44 |
mtk_fsp_init(RAMSTAGE_SOC_INIT); |
| 45 |
mtk_fsp_add_param(FSP_PARAM_TYPE_STORAGE, sizeof(storage_type), &storage_type); |
| 46 |
pi_image_add_mtk_fsp_params(); |
| 47 |
mtk_fsp_load_and_run(); |
| 48 |
|
| 49 |
mtk_mmu_disable_l2c_sram(); |
| 50 |
sspm_init(); |
| 51 |
gpueb_init(); |
| 52 |
mcupm_init(); |
| 53 |
mt6685_init_pmif_arb(); |
| 54 |
} |
| 55 |
|
| 56 |
static struct device_operations soc_ops = { |
| 57 |
.read_resources = soc_read_resources, |
| 58 |
.set_resources = noop_set_resources, |
| 59 |
.init = soc_init, |
| 60 |
}; |
| 61 |
|
| 62 |
static struct device_operations pci_domain_ops = { |
| 63 |
.read_resources = &mtk_pcie_domain_read_resources, |
| 64 |
.set_resources = &mtk_pcie_domain_set_resources, |
| 65 |
.scan_bus = &pci_host_bridge_scan_bus, |
| 66 |
.enable = &mtk_pcie_domain_enable, |
| 67 |
}; |
| 68 |
|
| 69 |
static void enable_soc_dev(struct device *dev) |
| 70 |
{ |
| 71 |
if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
| 72 |
dev->ops = &soc_ops; |
| 73 |
} else if (dev->path.type == DEVICE_PATH_DOMAIN) { |
| 74 |
if (mainboard_needs_pcie_init()) |
| 75 |
dev->ops = &pci_domain_ops; |
| 76 |
else |
| 77 |
printk(BIOS_DEBUG, "Skip setting PCIe ops\n"); |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
struct chip_operations soc_mediatek_mt8196_ops = { |
| 82 |
.name = "SOC Mediatek MT8196", |
| 83 |
.enable_dev = enable_soc_dev, |
| 84 |
}; |