Ravi Kumar Bokka | 0c9eb31 | 2021-03-31 08:04:13 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Ravi Kumar Bokka | 0c9eb31 | 2021-03-31 08:04:13 +0530 | [diff] [blame] | 3 | #include <device/device.h> |
| 4 | #include <soc/mmu.h> |
| 5 | #include <soc/mmu_common.h> |
| 6 | #include <soc/symbols_common.h> |
Ravi Kumar Bokka | b0d48ed | 2021-01-21 02:54:48 +0530 | [diff] [blame] | 7 | #include <soc/cpucp.h> |
Prasad Malisetty | 78298f5 | 2022-07-25 13:35:05 +0530 | [diff] [blame] | 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, |
Arthur Heymans | 0b0113f | 2023-08-31 17:09:28 +0200 | [diff] [blame] | 13 | .scan_bus = &pci_host_bridge_scan_bus, |
Prasad Malisetty | 78298f5 | 2022-07-25 13:35:05 +0530 | [diff] [blame] | 14 | .enable = &qcom_setup_pcie_host, |
| 15 | }; |
Ravi Kumar Bokka | 0c9eb31 | 2021-03-31 08:04:13 +0530 | [diff] [blame] | 16 | |
| 17 | static void soc_read_resources(struct device *dev) |
| 18 | { |
T Michael Turney | 730107e | 2022-01-19 18:27:47 -0800 | [diff] [blame] | 19 | void *start = NULL; |
| 20 | void *end = NULL; |
| 21 | |
Kyösti Mälkki | f35c074 | 2021-06-26 14:12:54 +0300 | [diff] [blame] | 22 | ram_range(dev, 0, (uintptr_t)ddr_region->offset, ddr_region->size); |
| 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)); |
T Michael Turney | 730107e | 2022-01-19 18:27:47 -0800 | [diff] [blame] | 28 | if (soc_modem_carve_out(&start, &end)) |
Kyösti Mälkki | f35c074 | 2021-06-26 14:12:54 +0300 | [diff] [blame] | 29 | reserved_ram_range(dev, 6, (uintptr_t)start, end - start); |
Ravi Kumar Bokka | 0c9eb31 | 2021-03-31 08:04:13 +0530 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | static void soc_init(struct device *dev) |
| 33 | { |
Ravi Kumar Bokka | b0d48ed | 2021-01-21 02:54:48 +0530 | [diff] [blame] | 34 | cpucp_fw_load_reset(); |
Ravi Kumar Bokka | 0c9eb31 | 2021-03-31 08:04:13 +0530 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | static struct device_operations soc_ops = { |
| 38 | .read_resources = soc_read_resources, |
Kshitiz Godara | b53ef22 | 2022-06-23 10:20:38 +0530 | [diff] [blame] | 39 | .set_resources = noop_set_resources, |
Ravi Kumar Bokka | 0c9eb31 | 2021-03-31 08:04:13 +0530 | [diff] [blame] | 40 | .init = soc_init, |
| 41 | }; |
| 42 | |
| 43 | static void enable_soc_dev(struct device *dev) |
| 44 | { |
Prasad Malisetty | 78298f5 | 2022-07-25 13:35:05 +0530 | [diff] [blame] | 45 | /* Set the operations if it is a special bus type */ |
Shelley Chen | f6307ca | 2022-11-16 17:02:32 -0800 | [diff] [blame] | 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) |
Prasad Malisetty | 78298f5 | 2022-07-25 13:35:05 +0530 | [diff] [blame] | 52 | dev->ops = &soc_ops; |
Ravi Kumar Bokka | 0c9eb31 | 2021-03-31 08:04:13 +0530 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | struct chip_operations soc_qualcomm_sc7280_ops = { |
| 56 | CHIP_NAME("SOC Qualcomm SC7280") |
| 57 | .enable_dev = enable_soc_dev, |
| 58 | }; |