blob: b49dac0079c92689ebeed508587dc3007bbf500d [file] [log] [blame]
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2016 Kyösti Mälkki
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
Elyes HAOUAS19f5ba82018-10-14 14:52:06 +020016#include <Porting.h>
17#include <AGESA.h>
Kyösti Mälkki64df52e2017-09-01 06:13:08 +030018#include <arch/io.h>
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020019#include <cbmem.h>
Nico Huber3e1b3b12018-10-07 12:45:47 +020020#include <cf9_reset.h>
Elyes HAOUAS20eaef02019-03-29 17:45:28 +010021#include <console/console.h>
Kyösti Mälkki64df52e2017-09-01 06:13:08 +030022#include <device/device.h>
23#include <device/pci_def.h>
Patrick Rudolphe56189c2018-04-18 10:11:59 +020024#include <device/pci_ops.h>
Kyösti Mälkki64df52e2017-09-01 06:13:08 +030025#include <smp/node.h>
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020026#include <northbridge/amd/agesa/state_machine.h>
27#include <northbridge/amd/agesa/agesa_helper.h>
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020028#include <sb_cimx.h>
29
30void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset)
31{
Kyösti Mälkki3d5e1e52019-12-03 14:06:02 +020032 if (!boot_cpu())
33 return;
34
Kyösti Mälkki520717d2019-12-15 21:37:48 +020035 sb_Poweron_Init();
Kyösti Mälkki3d5e1e52019-12-03 14:06:02 +020036
Kyösti Mälkki64df52e2017-09-01 06:13:08 +030037 /* Reboots with outb(3,0x92), outb(4,0xcf9) or triple-fault all
38 * would fail later in AmdInitPost(), when DRAM is already configured
39 * and C6DramLock bit has been set.
40 *
41 * As a workaround, do a hard reset to clear C6DramLock bit.
42 */
Kyösti Mälkki3d5e1e52019-12-03 14:06:02 +020043
Kyösti Mälkki64df52e2017-09-01 06:13:08 +030044#ifdef __SIMPLE_DEVICE__
45 pci_devfn_t dev = PCI_DEV(0, 0x18, 2);
46#else
Kyösti Mälkki4ad7f5b2018-05-22 01:15:17 +030047 struct device *dev = pcidev_on_root(0x18, 2);
Kyösti Mälkki64df52e2017-09-01 06:13:08 +030048#endif
Kyösti Mälkki3d5e1e52019-12-03 14:06:02 +020049 u32 mct_cfg_lo = pci_read_config32(dev, 0x118);
50 if (mct_cfg_lo & (1<<19)) {
51 printk(BIOS_CRIT, "C6DramLock is set, resetting\n");
52 system_reset();
Kyösti Mälkki64df52e2017-09-01 06:13:08 +030053 }
Kyösti Mälkki3d5e1e52019-12-03 14:06:02 +020054
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020055}
56
57void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early)
58{
59}
60
61void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post)
62{
63}
64
65void platform_AfterInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post)
66{
67 backup_top_of_low_cacheable(Post->MemConfig.Sub4GCacheTop);
68}
69
70void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
71{
72 OemInitResume(&Resume->S3DataBlock);
73}
74
75void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume)
76{
77}
78
79void platform_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env)
80{
81 EmptyHeap();
82}
83
84void platform_AfterInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env)
85{
86 amd_initenv();
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020087}
88
89void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
90{
91 OemS3LateRestore(&S3Late->S3DataBlock);
92}
93
94void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late)
95{
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020096}
97
98void platform_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid)
99{
100 sb_After_Pci_Init();
101 sb_Mid_Post_Init();
102
103 amd_initcpuio();
104}
105
Michał Żygowski506b9c12019-12-20 16:57:13 +0100106void platform_BeforeInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late)
107{
108}
109
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +0200110void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late)
111{
112 sb_Late_Post();
113}
114
115void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save)
116{
117 OemS3Save(&S3Save->S3DataBlock);
118}