blob: 87fcd4cf356f8dbba1b5a8de0e902691f6767aec [file] [log] [blame]
Edward O'Callaghan32960e32014-11-23 17:38:52 +11001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
Kyösti Mälkkif21c2ac2014-10-19 09:35:18 +030020#include <northbridge/amd/agesa/agesawrapper.h>
Edward O'Callaghan32960e32014-11-23 17:38:52 +110021
22#include <arch/acpi.h>
23#include <arch/cpu.h>
24#include <arch/io.h>
25#include <arch/stages.h>
26#include <cbmem.h>
27#include <console/console.h>
28#include <cpu/amd/agesa/s3_resume.h>
29#include <cpu/x86/bist.h>
30#include <cpu/x86/lapic.h>
31#include <cpu/amd/car.h>
32#include <device/pci_def.h>
33#include <device/pci_ids.h>
34#include <stdint.h>
35#include <string.h>
36#include <southbridge/amd/agesa/hudson/hudson.h>
37
38void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
39{
40 u32 val;
Kyösti Mälkki48518f02014-11-25 14:20:57 +020041 amd_initmmio();
Edward O'Callaghan32960e32014-11-23 17:38:52 +110042
Edward O'Callaghan32960e32014-11-23 17:38:52 +110043 hudson_lpc_port80();
44
45 if (!cpu_init_detectedx && boot_cpu()) {
46 post_code(0x30);
47
48 post_code(0x31);
49 console_init();
50 }
51
52 /* Halt if there was a built in self test failure */
53 post_code(0x34);
54 report_bist_failure(bist);
55
56 /* Load MPB */
57 val = cpuid_eax(1);
58 printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val);
59 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx);
60
61 post_code(0x37);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030062 agesawrapper_amdinitreset();
Edward O'Callaghan32960e32014-11-23 17:38:52 +110063 post_code(0x39);
64
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030065 agesawrapper_amdinitearly();
Kyösti Mälkki78c5d582015-01-09 23:48:47 +020066 int s3resume = acpi_is_wakeup_s3();
Edward O'Callaghan32960e32014-11-23 17:38:52 +110067 if (!s3resume) {
68 post_code(0x40);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030069 agesawrapper_amdinitpost();
Edward O'Callaghan32960e32014-11-23 17:38:52 +110070 post_code(0x41);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030071 agesawrapper_amdinitenv();
Edward O'Callaghan32960e32014-11-23 17:38:52 +110072 disable_cache_as_ram();
73 } else { /* S3 detect */
74 printk(BIOS_INFO, "S3 detected\n");
75
76 post_code(0x60);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030077 agesawrapper_amdinitresume();
Edward O'Callaghan32960e32014-11-23 17:38:52 +110078
Kyösti Mälkki48518f02014-11-25 14:20:57 +020079 amd_initcpuio();
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030080 agesawrapper_amds3laterestore();
Edward O'Callaghan32960e32014-11-23 17:38:52 +110081
82 post_code(0x61);
83 prepare_for_resume();
84 }
85
86 post_code(0x50);
87 copy_and_run();
88
89 post_code(0x54); /* Should never see this post code. */
90}