blob: 01f463a0cb7f397f5f27428d22bea51766c44903 [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
20#include "agesawrapper.h"
21#include <northbridge/amd/agesa/agesawrapper_call.h>
22
23#include <arch/acpi.h>
24#include <arch/cpu.h>
25#include <arch/io.h>
26#include <arch/stages.h>
27#include <cbmem.h>
28#include <console/console.h>
29#include <cpu/amd/agesa/s3_resume.h>
30#include <cpu/x86/bist.h>
31#include <cpu/x86/lapic.h>
32#include <cpu/amd/car.h>
33#include <device/pci_def.h>
34#include <device/pci_ids.h>
35#include <stdint.h>
36#include <string.h>
37#include <southbridge/amd/agesa/hudson/hudson.h>
38
39void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
40{
41 u32 val;
42 AGESAWRAPPER_PRE_CONSOLE(amdinitmmio);
43
44 hudson_lpc_port80();
45
46 if (!cpu_init_detectedx && boot_cpu()) {
47 post_code(0x30);
48
49 post_code(0x31);
50 console_init();
51 }
52
53 /* Halt if there was a built in self test failure */
54 post_code(0x34);
55 report_bist_failure(bist);
56
57 /* Load MPB */
58 val = cpuid_eax(1);
59 printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val);
60 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx);
61
62 post_code(0x37);
63 AGESAWRAPPER(amdinitreset);
64 post_code(0x39);
65
66 AGESAWRAPPER(amdinitearly);
67 int s3resume = acpi_is_wakeup_early() && acpi_s3_resume_allowed();
68 if (!s3resume) {
69 post_code(0x40);
70 AGESAWRAPPER(amdinitpost);
71 post_code(0x41);
72 AGESAWRAPPER(amdinitenv);
73 disable_cache_as_ram();
74 } else { /* S3 detect */
75 printk(BIOS_INFO, "S3 detected\n");
76
77 post_code(0x60);
78 AGESAWRAPPER(amdinitresume);
79
80 AGESAWRAPPER(amds3laterestore);
81
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}