blob: d78c575ef3b3b3103e5033baec738cd1f7fec2be [file] [log] [blame]
Krystian Hebel0d2dbca2019-04-23 19:28:16 +02001/*
2 * This file is part of the coreboot project.
3 *
Krystian Hebel0d2dbca2019-04-23 19:28:16 +02004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include "Porting.h"
16#include "AGESA.h"
17
18#include <cbmem.h>
Michał Żygowski7c071102019-12-20 17:18:42 +010019#include <device/device.h>
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020020#include <northbridge/amd/agesa/state_machine.h>
21#include <northbridge/amd/agesa/agesa_helper.h>
Michał Żygowski3fbd2af2020-03-19 15:39:12 +010022#include <northbridge/amd/pi/nb_common.h>
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020023
24void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset)
25{
26}
27
28void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early)
29{
Michał Żygowski7c071102019-12-20 17:18:42 +010030 Early->GnbConfig.PsppPolicy = PsppDisabled;
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020031}
32
33void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post)
34{
Michał Żygowski7c071102019-12-20 17:18:42 +010035 Post->MemConfig.UmaMode = CONFIG(GFXUMA) ? UMA_AUTO : UMA_NONE;
36 Post->MemConfig.UmaSize = 0;
37 Post->MemConfig.BottomIo = (UINT16)(CONFIG_BOTTOMIO_POSITION >> 24);
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020038}
39
40void platform_AfterInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post)
41{
42 /* If UMA is enabled we currently have it below TOP_MEM as well.
43 * UMA may or may not be cacheable, so Sub4GCacheTop could be
44 * higher than UmaBase. With UMA_NONE we see UmaBase==0. */
45 if (Post->MemConfig.UmaBase)
46 backup_top_of_low_cacheable(Post->MemConfig.UmaBase << 16);
47 else
48 backup_top_of_low_cacheable(Post->MemConfig.Sub4GCacheTop);
49}
50
51
52void platform_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env)
53{
54 EmptyHeap();
55}
56
57void platform_AfterInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env)
58{
59}
60
61void platform_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid)
62{
63 amd_initcpuio();
Michał Żygowski7c071102019-12-20 17:18:42 +010064
65 /* 0 iGpuVgaAdapter, 1 iGpuVgaNonAdapter; */
66 Mid->GnbMidConfiguration.iGpuVgaMode = 0;
Michał Żygowski3fbd2af2020-03-19 15:39:12 +010067 Mid->GnbMidConfiguration.GnbIoapicAddress = IO_APIC2_ADDR;
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020068}
69
Michał Żygowski506b9c12019-12-20 16:57:13 +010070void platform_BeforeInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late)
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020071{
Michał Żygowski7c071102019-12-20 17:18:42 +010072 const struct device *iommu_dev = pcidev_on_root(0, 2);
73
74 if (iommu_dev && iommu_dev->enabled) {
75 /* According to AGESA headers these must be set to sane values
76 * when IOMMU build config is enabled otherwise AGESA will skip
77 * it during IOMMU init and IVRS generation.
78 */
79 Late->GnbLateConfiguration.GnbIoapicId = CONFIG_MAX_CPUS + 1;
80 Late->GnbLateConfiguration.FchIoapicId = CONFIG_MAX_CPUS;
81 }
82
83 /* Code for creating CDIT requires hop count table. If it is not
84 * present AGESA_ERROR is returned, which confuses users. CDIT is not
85 * written to the ACPI tables anyway. */
86 Late->PlatformConfig.UserOptionCdit = 0;
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020087}
88
Michał Żygowski506b9c12019-12-20 16:57:13 +010089void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late)
90{
91}
Krystian Hebel0d2dbca2019-04-23 19:28:16 +020092
93void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
94{
95}
96
97void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
98{
99}
100
101void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
102{
103}
104
105void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
106{
107 amd_initcpuio();
108}
109
110void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save)
111{
112}