blob: 5f018a757c9ea241c31917fcbc81495fe2589738 [file] [log] [blame]
Bruce Griffith79f47cf2014-08-15 12:38:21 -06001/*
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 <stdint.h>
21#include <string.h>
22#include <device/pci_def.h>
23#include <device/pci_ids.h>
24#include <arch/acpi.h>
25#include <arch/io.h>
26#include <arch/stages.h>
27#include <device/pnp_def.h>
28#include <arch/cpu.h>
29#include <cpu/x86/lapic.h>
30#include <console/console.h>
31#include <console/loglevel.h>
Edward O'Callaghanbf9d1222014-10-29 09:26:00 +110032#include <cpu/amd/car.h>
Bruce Griffith79f47cf2014-08-15 12:38:21 -060033#include "agesawrapper.h"
34#include <northbridge/amd/agesa/agesawrapper_call.h>
35#include "cpu/x86/bist.h"
36#include "cpu/x86/lapic.h"
37#include "southbridge/amd/agesa/hudson/hudson.h"
38#include "cpu/amd/agesa/s3_resume.h"
39
40void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
41{
42 u32 val;
43 volatile int halt = 0;
Bruce Griffith79f47cf2014-08-15 12:38:21 -060044
45 /*
46 * In Hudson RRG, PMIOxD2[5:4] is "Drive strength control for
47 * LpcClk[1:0]". This following register setting has been
48 * replicated in every reference design since Parmer, so it is
49 * believed to be required even though it is not documented in
50 * the SoC BKDGs. Without this setting, there is no serial
51 * output.
52 */
53 outb(0xD2, 0xcd6);
54 outb(0x00, 0xcd7);
55
Kyösti Mälkki30fbb4c2014-10-20 07:04:55 +030056 AGESAWRAPPER_PRE_CONSOLE(amdinitmmio);
Bruce Griffith79f47cf2014-08-15 12:38:21 -060057
58 hudson_lpc_port80();
59
60 if (!cpu_init_detectedx && boot_cpu()) {
61 post_code(0x30);
62
63 post_code(0x31);
64 console_init();
65 }
66
67 if(boot_cpu()) {
68 while(halt);
69 }
70 /* Halt if there was a built in self test failure */
71 post_code(0x34);
72 report_bist_failure(bist);
73
74 /* Load MPB */
75 val = cpuid_eax(1);
76 printk(BIOS_DEBUG, "BSP Family_Model: %08x \n", val);
77 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx \n", cpu_init_detectedx);
78
79 /*
80 * This refers to LpcClkDrvSth settling time. Without this setting, processor
81 * initialization is slow or incorrect, so this wait has been replicated from
82 * earlier development boards.
83 */
84 {
85 int i;
86 for(i = 0; i < 200000; i++) inb(0xCD6);
87 }
88
89 post_code(0x37);
90 AGESAWRAPPER(amdinitreset);
91
92 post_code(0x38);
93 printk(BIOS_DEBUG, "Got past avalon_early_setup\n");
94
95 post_code(0x39);
96 AGESAWRAPPER(amdinitearly);
97 int s3resume = acpi_is_wakeup_early() && acpi_s3_resume_allowed();
98 if (!s3resume) {
99 post_code(0x40);
100 AGESAWRAPPER(amdinitpost);
101
102 //PspMboxBiosCmdDramInfo();
103 post_code(0x41);
104 AGESAWRAPPER(amdinitenv);
105 /*
106 If code hangs here, please check cahaltasm.S
107 */
108 disable_cache_as_ram();
109 } else { /* S3 detect */
110 printk(BIOS_INFO, "S3 detected\n");
111
112 post_code(0x60);
113 AGESAWRAPPER(amdinitresume);
114
115 AGESAWRAPPER(amds3laterestore);
116
117 post_code(0x61);
118 prepare_for_resume();
119 }
120
121 outb(0xEA, 0xCD6);
122 outb(0x1, 0xcd7);
123
124 post_code(0x50);
125 copy_and_run();
126
127 post_code(0x54); /* Should never see this post code. */
128}