blob: 0b96d3aa328508a776878ac9b82b631af9a3f35b [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Krystian Hebel0d2dbca2019-04-23 19:28:16 +02003
4#include "Porting.h"
5#include "AGESA.h"
6
7#include <cbmem.h>
Michał Żygowski7c071102019-12-20 17:18:42 +01008#include <device/device.h>
Krystian Hebel0d2dbca2019-04-23 19:28:16 +02009#include <northbridge/amd/agesa/state_machine.h>
10#include <northbridge/amd/agesa/agesa_helper.h>
Michał Żygowski3fbd2af2020-03-19 15:39:12 +010011#include <northbridge/amd/pi/nb_common.h>
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020012
13void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset)
14{
15}
16
17void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early)
18{
Michał Żygowski7c071102019-12-20 17:18:42 +010019 Early->GnbConfig.PsppPolicy = PsppDisabled;
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020020}
21
22void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post)
23{
Michał Żygowski7c071102019-12-20 17:18:42 +010024 Post->MemConfig.UmaMode = CONFIG(GFXUMA) ? UMA_AUTO : UMA_NONE;
25 Post->MemConfig.UmaSize = 0;
26 Post->MemConfig.BottomIo = (UINT16)(CONFIG_BOTTOMIO_POSITION >> 24);
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020027}
28
29void platform_AfterInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post)
30{
31 /* If UMA is enabled we currently have it below TOP_MEM as well.
32 * UMA may or may not be cacheable, so Sub4GCacheTop could be
33 * higher than UmaBase. With UMA_NONE we see UmaBase==0. */
34 if (Post->MemConfig.UmaBase)
35 backup_top_of_low_cacheable(Post->MemConfig.UmaBase << 16);
36 else
37 backup_top_of_low_cacheable(Post->MemConfig.Sub4GCacheTop);
38}
39
40
41void 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 */
68 Late->GnbLateConfiguration.GnbIoapicId = CONFIG_MAX_CPUS + 1;
69 Late->GnbLateConfiguration.FchIoapicId = CONFIG_MAX_CPUS;
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 Hebel0d2dbca2019-04-23 19:28:16 +020076}
77
Michał Żygowski506b9c12019-12-20 16:57:13 +010078void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late)
79{
80}
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020081
82void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
83{
84}
85
86void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
87{
88}
89
90void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
91{
92}
93
94void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
95{
96 amd_initcpuio();
97}
98
99void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save)
100{
101}