blob: f250168fdda98f2d1deccff78a631255c87f8892 [file] [log] [blame]
WANG Siyuan01e3e062015-05-20 14:47:58 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 Advanced Micro Devices, Inc.
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.
WANG Siyuan01e3e062015-05-20 14:47:58 +080014 */
15
16#include <console/console.h>
17#include <arch/acpi.h>
zbao1897c2c2015-11-05 20:25:59 +080018#include <arch/io.h>
Elyes HAOUASd2b9ec12018-10-27 09:41:02 +020019#include <arch/cpu.h>
WANG Siyuan01e3e062015-05-20 14:47:58 +080020#include <cpu/x86/lapic.h>
21#include <cpu/x86/bist.h>
22#include <cpu/amd/car.h>
Kyösti Mälkkibebd7662017-04-13 15:25:43 +030023#include <northbridge/amd/agesa/state_machine.h>
WANG Siyuan01e3e062015-05-20 14:47:58 +080024#include <northbridge/amd/pi/agesawrapper.h>
25#include <northbridge/amd/pi/agesawrapper_call.h>
26#include <southbridge/amd/pi/hudson/hudson.h>
27
28void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
29{
30 u32 val;
WANG Siyuan01e3e062015-05-20 14:47:58 +080031
WANG Siyuan01e3e062015-05-20 14:47:58 +080032 hudson_lpc_port80();
33
34 if (!cpu_init_detectedx && boot_cpu()) {
35 post_code(0x30);
36
Zheng Bao22861382015-11-21 12:19:22 +080037#if IS_ENABLED(CONFIG_HUDSON_UART)
38 configure_hudson_uart();
39#endif
WANG Siyuan01e3e062015-05-20 14:47:58 +080040 post_code(0x31);
41 console_init();
42 }
43
44 /* Halt if there was a built in self test failure */
45 post_code(0x34);
zbaofe234c42015-07-02 16:53:09 -040046 report_bist_failure(bist & 0x7FFFFFFF); /* Mask bit 31. One result of Silicon Observation */
WANG Siyuan01e3e062015-05-20 14:47:58 +080047
48 /* Load MPB */
49 val = cpuid_eax(1);
Elyes HAOUASe53e488c2016-08-21 12:19:25 +020050 printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val);
51 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx);
WANG Siyuan01e3e062015-05-20 14:47:58 +080052
53 post_code(0x37);
54 AGESAWRAPPER(amdinitreset);
55 post_code(0x38);
56 printk(BIOS_DEBUG, "Got past agesawrapper_amdinitreset\n");
57
58 post_code(0x39);
59 AGESAWRAPPER(amdinitearly);
WANG Siyuan01e3e062015-05-20 14:47:58 +080060
Kyösti Mälkki1b183aa2017-02-26 10:11:21 +020061 post_code(0x40);
62 AGESAWRAPPER(amdinitpost);
Kyösti Mälkkibebd7662017-04-13 15:25:43 +030063}
64
65void agesa_postcar(struct sysinfo *cb)
66{
Kyösti Mälkki1b183aa2017-02-26 10:11:21 +020067 post_code(0x41);
68 AGESAWRAPPER(amdinitenv);
WANG Siyuan01e3e062015-05-20 14:47:58 +080069
Kyösti Mälkki1b183aa2017-02-26 10:11:21 +020070 if (acpi_is_wakeup_s4()) {
zbao1897c2c2015-11-05 20:25:59 +080071 outb(0xEE, PM_INDEX);
72 outb(0x8, PM_DATA);
73 }
WANG Siyuan01e3e062015-05-20 14:47:58 +080074}