blob: a05e9e04e814e1fb3fca8154e0dc31449abd5ceb [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Krystian Hebel0d2dbca2019-04-23 19:28:16 +02002
Kyösti Mälkki2446c1e2020-07-09 07:13:37 +03003#include <amdblocks/biosram.h>
Kyösti Mälkkid1534e42023-04-09 10:01:58 +03004#include <amdblocks/ioapic.h>
Kyösti Mälkki2446c1e2020-07-09 07:13:37 +03005
Krystian Hebel0d2dbca2019-04-23 19:28:16 +02006#include "Porting.h"
7#include "AGESA.h"
8
Michał Żygowski7c071102019-12-20 17:18:42 +01009#include <device/device.h>
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020010#include <northbridge/amd/agesa/state_machine.h>
11#include <northbridge/amd/agesa/agesa_helper.h>
Angel Ponsec5cf152020-11-10 20:42:07 +010012#include <northbridge/amd/nb_common.h>
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020013
14void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset)
15{
16}
17
18void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early)
19{
Michał Żygowski7c071102019-12-20 17:18:42 +010020 Early->GnbConfig.PsppPolicy = PsppDisabled;
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020021}
22
23void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post)
24{
Michał Żygowski7c071102019-12-20 17:18:42 +010025 Post->MemConfig.UmaMode = CONFIG(GFXUMA) ? UMA_AUTO : UMA_NONE;
26 Post->MemConfig.UmaSize = 0;
27 Post->MemConfig.BottomIo = (UINT16)(CONFIG_BOTTOMIO_POSITION >> 24);
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020028}
29
30void 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 Hebel0d2dbca2019-04-23 19:28:16 +020041void platform_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env)
42{
43 EmptyHeap();
44}
45
46void platform_AfterInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env)
47{
48}
49
50void platform_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid)
51{
52 amd_initcpuio();
Michał Żygowski7c071102019-12-20 17:18:42 +010053
54 /* 0 iGpuVgaAdapter, 1 iGpuVgaNonAdapter; */
55 Mid->GnbMidConfiguration.iGpuVgaMode = 0;
Michał Żygowski3fbd2af2020-03-19 15:39:12 +010056 Mid->GnbMidConfiguration.GnbIoapicAddress = IO_APIC2_ADDR;
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020057}
58
Michał Żygowski506b9c12019-12-20 16:57:13 +010059void platform_BeforeInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late)
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020060{
Michał Żygowski7c071102019-12-20 17:18:42 +010061 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älkki8f86fa02022-12-05 19:31:01 +020068 Late->GnbLateConfiguration.GnbIoapicId = GNB_IOAPIC_ID;
69 Late->GnbLateConfiguration.FchIoapicId = FCH_IOAPIC_ID;
Michał Żygowski7c071102019-12-20 17:18:42 +010070 }
71
Felix Held0a2c9d72023-03-02 21:01:37 +010072 /* Make binaryPI use \_SB_ as processor object scope in PSTATE SSDT */
73 Late->PlatformConfig.ProcessorScopeInSb = true;
74
Michał Żygowski7c071102019-12-20 17:18:42 +010075 /* Code for creating CDIT requires hop count table. If it is not
76 * present AGESA_ERROR is returned, which confuses users. CDIT is not
77 * written to the ACPI tables anyway. */
78 Late->PlatformConfig.UserOptionCdit = 0;
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020079}
80
Michał Żygowski506b9c12019-12-20 16:57:13 +010081void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late)
82{
83}
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020084
85void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
86{
87}
88
89void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
90{
91}
92
93void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
94{
95}
96
97void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
98{
99 amd_initcpuio();
100}
101
102void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save)
103{
104}