1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <device/device.h>
4 #include <soc/mmu.h>
5 #include <soc/mmu_common.h>
6 #include <soc/symbols_common.h>
7 #include <soc/cpucp.h>
8 #include <soc/pcie.h>
9
10 static struct device_operations pci_domain_ops = {
11 .read_resources = &qcom_pci_domain_read_resources,
12 .set_resources = &pci_domain_set_resources,
13 .scan_bus = &pci_host_bridge_scan_bus,
14 .enable = &qcom_setup_pcie_host,
15 };
16
soc_read_resources(struct device * dev)17 static void soc_read_resources(struct device *dev)
18 {
19 void *start = NULL;
20 void *end = NULL;
21
22 ram_range(dev, 0, (uintptr_t)region_offset(ddr_region), region_sz(ddr_region));
23 reserved_ram_range(dev, 1, (uintptr_t)_dram_soc, REGION_SIZE(dram_soc));
24 reserved_ram_range(dev, 2, (uintptr_t)_dram_wlan, REGION_SIZE(dram_wlan));
25 reserved_ram_range(dev, 3, (uintptr_t)_dram_wpss, REGION_SIZE(dram_wpss));
26 reserved_ram_range(dev, 4, (uintptr_t)_dram_aop, REGION_SIZE(dram_aop));
27 reserved_ram_range(dev, 5, (uintptr_t)_dram_cpucp, REGION_SIZE(dram_cpucp));
28 if (soc_modem_carve_out(&start, &end))
29 reserved_ram_range(dev, 6, (uintptr_t)start, end - start);
30 }
31
soc_init(struct device * dev)32 static void soc_init(struct device *dev)
33 {
34 cpucp_fw_load_reset();
35 }
36
37 static struct device_operations soc_ops = {
38 .read_resources = soc_read_resources,
39 .set_resources = noop_set_resources,
40 .init = soc_init,
41 };
42
enable_soc_dev(struct device * dev)43 static void enable_soc_dev(struct device *dev)
44 {
45 /* Set the operations if it is a special bus type */
46 if (dev->path.type == DEVICE_PATH_DOMAIN) {
47 if (mainboard_needs_pcie_init())
48 dev->ops = &pci_domain_ops;
49 else
50 printk(BIOS_DEBUG, "Skip setting PCIe ops\n");
51 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
52 dev->ops = &soc_ops;
53 }
54
55 struct chip_operations soc_qualcomm_sc7280_ops = {
56 .name = "SOC Qualcomm SC7280",
57 .enable_dev = enable_soc_dev,
58 };
59