Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Krystian Hebel | 0d2dbca | 2019-04-23 19:28:16 +0200 | [diff] [blame] | 2 | |
Kyösti Mälkki | 2446c1e | 2020-07-09 07:13:37 +0300 | [diff] [blame] | 3 | #include <amdblocks/biosram.h> |
| 4 | |
Krystian Hebel | 0d2dbca | 2019-04-23 19:28:16 +0200 | [diff] [blame] | 5 | #include "Porting.h" |
| 6 | #include "AGESA.h" |
| 7 | |
Michał Żygowski | 7c07110 | 2019-12-20 17:18:42 +0100 | [diff] [blame] | 8 | #include <device/device.h> |
Krystian Hebel | 0d2dbca | 2019-04-23 19:28:16 +0200 | [diff] [blame] | 9 | #include <northbridge/amd/agesa/state_machine.h> |
| 10 | #include <northbridge/amd/agesa/agesa_helper.h> |
Angel Pons | ec5cf15 | 2020-11-10 20:42:07 +0100 | [diff] [blame] | 11 | #include <northbridge/amd/nb_common.h> |
Kyösti Mälkki | 8f86fa0 | 2022-12-05 19:31:01 +0200 | [diff] [blame^] | 12 | #include <southbridge/amd/pi/hudson/ioapic.h> |
Krystian Hebel | 0d2dbca | 2019-04-23 19:28:16 +0200 | [diff] [blame] | 13 | |
| 14 | void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset) |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early) |
| 19 | { |
Michał Żygowski | 7c07110 | 2019-12-20 17:18:42 +0100 | [diff] [blame] | 20 | Early->GnbConfig.PsppPolicy = PsppDisabled; |
Krystian Hebel | 0d2dbca | 2019-04-23 19:28:16 +0200 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post) |
| 24 | { |
Michał Żygowski | 7c07110 | 2019-12-20 17:18:42 +0100 | [diff] [blame] | 25 | Post->MemConfig.UmaMode = CONFIG(GFXUMA) ? UMA_AUTO : UMA_NONE; |
| 26 | Post->MemConfig.UmaSize = 0; |
| 27 | Post->MemConfig.BottomIo = (UINT16)(CONFIG_BOTTOMIO_POSITION >> 24); |
Krystian Hebel | 0d2dbca | 2019-04-23 19:28:16 +0200 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | void platform_AfterInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post) |
| 31 | { |
| 32 | /* If UMA is enabled we currently have it below TOP_MEM as well. |
| 33 | * UMA may or may not be cacheable, so Sub4GCacheTop could be |
| 34 | * higher than UmaBase. With UMA_NONE we see UmaBase==0. */ |
| 35 | if (Post->MemConfig.UmaBase) |
| 36 | backup_top_of_low_cacheable(Post->MemConfig.UmaBase << 16); |
| 37 | else |
| 38 | backup_top_of_low_cacheable(Post->MemConfig.Sub4GCacheTop); |
| 39 | } |
| 40 | |
Krystian Hebel | 0d2dbca | 2019-04-23 19:28:16 +0200 | [diff] [blame] | 41 | void platform_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env) |
| 42 | { |
| 43 | EmptyHeap(); |
| 44 | } |
| 45 | |
| 46 | void platform_AfterInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env) |
| 47 | { |
| 48 | } |
| 49 | |
| 50 | void platform_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid) |
| 51 | { |
| 52 | amd_initcpuio(); |
Michał Żygowski | 7c07110 | 2019-12-20 17:18:42 +0100 | [diff] [blame] | 53 | |
| 54 | /* 0 iGpuVgaAdapter, 1 iGpuVgaNonAdapter; */ |
| 55 | Mid->GnbMidConfiguration.iGpuVgaMode = 0; |
Michał Żygowski | 3fbd2af | 2020-03-19 15:39:12 +0100 | [diff] [blame] | 56 | Mid->GnbMidConfiguration.GnbIoapicAddress = IO_APIC2_ADDR; |
Krystian Hebel | 0d2dbca | 2019-04-23 19:28:16 +0200 | [diff] [blame] | 57 | } |
| 58 | |
Michał Żygowski | 506b9c1 | 2019-12-20 16:57:13 +0100 | [diff] [blame] | 59 | void platform_BeforeInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late) |
Krystian Hebel | 0d2dbca | 2019-04-23 19:28:16 +0200 | [diff] [blame] | 60 | { |
Michał Żygowski | 7c07110 | 2019-12-20 17:18:42 +0100 | [diff] [blame] | 61 | const struct device *iommu_dev = pcidev_on_root(0, 2); |
| 62 | |
| 63 | if (iommu_dev && iommu_dev->enabled) { |
| 64 | /* According to AGESA headers these must be set to sane values |
| 65 | * when IOMMU build config is enabled otherwise AGESA will skip |
| 66 | * it during IOMMU init and IVRS generation. |
| 67 | */ |
Kyösti Mälkki | 8f86fa0 | 2022-12-05 19:31:01 +0200 | [diff] [blame^] | 68 | Late->GnbLateConfiguration.GnbIoapicId = GNB_IOAPIC_ID; |
| 69 | Late->GnbLateConfiguration.FchIoapicId = FCH_IOAPIC_ID; |
Michał Żygowski | 7c07110 | 2019-12-20 17:18:42 +0100 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | /* Code for creating CDIT requires hop count table. If it is not |
| 73 | * present AGESA_ERROR is returned, which confuses users. CDIT is not |
| 74 | * written to the ACPI tables anyway. */ |
| 75 | Late->PlatformConfig.UserOptionCdit = 0; |
Krystian Hebel | 0d2dbca | 2019-04-23 19:28:16 +0200 | [diff] [blame] | 76 | } |
| 77 | |
Michał Żygowski | 506b9c1 | 2019-12-20 16:57:13 +0100 | [diff] [blame] | 78 | void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late) |
| 79 | { |
| 80 | } |
Krystian Hebel | 0d2dbca | 2019-04-23 19:28:16 +0200 | [diff] [blame] | 81 | |
| 82 | void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume) |
| 83 | { |
| 84 | } |
| 85 | |
| 86 | void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume) |
| 87 | { |
| 88 | } |
| 89 | |
| 90 | void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late) |
| 91 | { |
| 92 | } |
| 93 | |
| 94 | void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late) |
| 95 | { |
| 96 | amd_initcpuio(); |
| 97 | } |
| 98 | |
| 99 | void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save) |
| 100 | { |
| 101 | } |