Macpaul Lin | 5d16f8d | 2022-08-11 16:27:10 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only OR MIT */ |
Yidi Lin | 24ea3f3 | 2021-01-07 20:25:54 +0800 | [diff] [blame] | 2 | |
Rex-BC Chen | 61be50d | 2021-08-10 12:39:32 +0800 | [diff] [blame] | 3 | #include <bootmem.h> |
Yu-Ping Wu | 3b9d6a4 | 2022-07-19 17:09:39 +0800 | [diff] [blame] | 4 | #include <console/console.h> |
Yidi Lin | 24ea3f3 | 2021-01-07 20:25:54 +0800 | [diff] [blame] | 5 | #include <device/device.h> |
Jianjun Wang | b4a7122 | 2021-07-14 15:41:20 +0800 | [diff] [blame] | 6 | #include <device/pci.h> |
Flora Fu | 5cd1871 | 2021-06-25 23:27:56 +0800 | [diff] [blame] | 7 | #include <soc/apusys.h> |
Yidi Lin | 78b29f4 | 2022-12-20 15:30:38 +0800 | [diff] [blame] | 8 | #include <soc/apusys_devapc.h> |
Nina Wu | c25aa5b | 2021-06-21 09:13:19 +0800 | [diff] [blame] | 9 | #include <soc/devapc.h> |
Rex-BC Chen | 61be50d | 2021-08-10 12:39:32 +0800 | [diff] [blame] | 10 | #include <soc/dfd.h> |
Yidi Lin | 24ea3f3 | 2021-01-07 20:25:54 +0800 | [diff] [blame] | 11 | #include <soc/emi.h> |
Rex-BC Chen | 8316db2 | 2021-08-13 16:34:26 +0800 | [diff] [blame] | 12 | #include <soc/hdmi.h> |
alex.miao | 4a2887f | 2021-05-17 21:58:55 +0800 | [diff] [blame] | 13 | #include <soc/mcupm.h> |
Yidi Lin | 27be904 | 2021-03-25 17:50:14 +0800 | [diff] [blame] | 14 | #include <soc/mmu_operations.h> |
Jianjun Wang | b4a7122 | 2021-07-14 15:41:20 +0800 | [diff] [blame] | 15 | #include <soc/pcie.h> |
Rex-BC Chen | ab2cbf7 | 2021-05-03 20:44:09 +0800 | [diff] [blame] | 16 | #include <soc/sspm.h> |
Yidi Lin | be8621d | 2021-04-19 16:06:55 +0800 | [diff] [blame] | 17 | #include <soc/ufs.h> |
Yidi Lin | 24ea3f3 | 2021-01-07 20:25:54 +0800 | [diff] [blame] | 18 | #include <symbols.h> |
| 19 | |
Rex-BC Chen | 61be50d | 2021-08-10 12:39:32 +0800 | [diff] [blame] | 20 | void bootmem_platform_add_ranges(void) |
| 21 | { |
| 22 | if (CONFIG(MTK_DFD)) |
| 23 | bootmem_add_range(DFD_DUMP_ADDRESS, DFD_DUMP_SIZE, BM_MEM_RESERVED); |
| 24 | } |
| 25 | |
Yidi Lin | 24ea3f3 | 2021-01-07 20:25:54 +0800 | [diff] [blame] | 26 | static void soc_read_resources(struct device *dev) |
| 27 | { |
Kyösti Mälkki | 85eb34e | 2022-06-20 14:13:36 +0300 | [diff] [blame] | 28 | ram_range(dev, 0, (uintptr_t)_dram, sdram_size()); |
Yidi Lin | 24ea3f3 | 2021-01-07 20:25:54 +0800 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | static void soc_init(struct device *dev) |
| 32 | { |
Yidi Lin | 27be904 | 2021-03-25 17:50:14 +0800 | [diff] [blame] | 33 | mtk_mmu_disable_l2c_sram(); |
Nina Wu | c25aa5b | 2021-06-21 09:13:19 +0800 | [diff] [blame] | 34 | dapc_init(); |
Yidi Lin | 78b29f4 | 2022-12-20 15:30:38 +0800 | [diff] [blame] | 35 | start_apusys_devapc(); |
Flora Fu | 5cd1871 | 2021-06-25 23:27:56 +0800 | [diff] [blame] | 36 | apusys_init(); |
alex.miao | 4a2887f | 2021-05-17 21:58:55 +0800 | [diff] [blame] | 37 | mcupm_init(); |
Rex-BC Chen | ab2cbf7 | 2021-05-03 20:44:09 +0800 | [diff] [blame] | 38 | sspm_init(); |
Rex-BC Chen | 61be50d | 2021-08-10 12:39:32 +0800 | [diff] [blame] | 39 | |
| 40 | if (CONFIG(MTK_DFD)) |
| 41 | dfd_init(); |
| 42 | |
Yidi Lin | be8621d | 2021-04-19 16:06:55 +0800 | [diff] [blame] | 43 | ufs_disable_refclk(); |
Rex-BC Chen | 8316db2 | 2021-08-13 16:34:26 +0800 | [diff] [blame] | 44 | hdmi_low_power_setting(); |
Yidi Lin | 24ea3f3 | 2021-01-07 20:25:54 +0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static struct device_operations soc_ops = { |
| 48 | .read_resources = soc_read_resources, |
Yu-Ping Wu | 39e6f85 | 2022-03-14 16:53:59 +0800 | [diff] [blame] | 49 | .set_resources = noop_set_resources, |
Yidi Lin | 24ea3f3 | 2021-01-07 20:25:54 +0800 | [diff] [blame] | 50 | .init = soc_init, |
| 51 | }; |
| 52 | |
Jianjun Wang | b4a7122 | 2021-07-14 15:41:20 +0800 | [diff] [blame] | 53 | static struct device_operations pci_domain_ops = { |
| 54 | .read_resources = &mtk_pcie_domain_read_resources, |
| 55 | .set_resources = &mtk_pcie_domain_set_resources, |
| 56 | .scan_bus = &pci_domain_scan_bus, |
| 57 | .enable = &mtk_pcie_domain_enable, |
| 58 | }; |
| 59 | |
Yidi Lin | 24ea3f3 | 2021-01-07 20:25:54 +0800 | [diff] [blame] | 60 | static void enable_soc_dev(struct device *dev) |
| 61 | { |
Jianjun Wang | b4a7122 | 2021-07-14 15:41:20 +0800 | [diff] [blame] | 62 | if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) |
| 63 | dev->ops = &soc_ops; |
Yu-Ping Wu | 3b9d6a4 | 2022-07-19 17:09:39 +0800 | [diff] [blame] | 64 | else if (dev->path.type == DEVICE_PATH_DOMAIN) { |
| 65 | if (mainboard_needs_pcie_init()) |
| 66 | dev->ops = &pci_domain_ops; |
| 67 | else |
| 68 | printk(BIOS_DEBUG, "Skip setting PCIe ops\n"); |
| 69 | } |
Yidi Lin | 24ea3f3 | 2021-01-07 20:25:54 +0800 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | struct chip_operations soc_mediatek_mt8195_ops = { |
| 73 | CHIP_NAME("SOC Mediatek MT8195") |
| 74 | .enable_dev = enable_soc_dev, |
| 75 | }; |