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