blob: 5deeaa8edaa1ab6fc2882af0c0f231fb506bcc7a [file] [log] [blame]
Fabian Kunkel171e2c92016-07-27 17:30:49 +02001/*
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
16#include <stdint.h>
17#include <string.h>
18#include <device/pci_def.h>
19#include <device/pci_ids.h>
20#include <arch/acpi.h>
21#include <arch/io.h>
22#include <arch/stages.h>
23#include <device/pnp_def.h>
24#include <arch/cpu.h>
25#include <cpu/x86/lapic.h>
26#include <console/console.h>
27#include <commonlib/loglevel.h>
28#include <cpu/amd/car.h>
29#include <northbridge/amd/pi/agesawrapper.h>
30#include <northbridge/amd/pi/agesawrapper_call.h>
31#include <cpu/x86/bist.h>
32#include <cpu/x86/lapic.h>
33#include <southbridge/amd/pi/hudson/hudson.h>
34#include <cpu/amd/pi/s3_resume.h>
Fabian Kunkelcf051832016-07-27 17:42:39 +020035#include <superio/fintek/common/fintek.h>
36#include <superio/fintek/f81866d/f81866d.h>
37
38#define SERIAL_DEV1 PNP_DEV(0x4e, F81866D_SP1)
Fabian Kunkel171e2c92016-07-27 17:30:49 +020039
40void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
41{
42 u32 val;
43
Kyösti Mälkki187543c2016-11-20 11:03:13 +020044 /* Must come first to enable PCI MMCONF. */
45 amd_initmmio();
46
Fabian Kunkel171e2c92016-07-27 17:30:49 +020047 /*
48 * In Hudson RRG, PMIOxD2[5:4] is "Drive strength control for
49 * LpcClk[1:0]". This following register setting has been
50 * replicated in every reference design since Parmer, so it is
51 * believed to be required even though it is not documented in
52 * the SoC BKDGs. Without this setting, there is no serial
53 * output.
54 */
55 outb(0xD2, 0xcd6);
56 outb(0x00, 0xcd7);
57
Fabian Kunkel171e2c92016-07-27 17:30:49 +020058 hudson_lpc_port80();
59
60 if (!cpu_init_detectedx && boot_cpu()) {
61 post_code(0x30);
Fabian Kunkelcf051832016-07-27 17:42:39 +020062 fintek_enable_serial(SERIAL_DEV1, CONFIG_TTYS0_BASE);
Fabian Kunkel171e2c92016-07-27 17:30:49 +020063 post_code(0x31);
64 console_init();
65 }
66
67 /* Halt if there was a built in self test failure */
68 post_code(0x34);
69 report_bist_failure(bist);
70
71 /* Load MPB */
72 val = cpuid_eax(1);
Elyes HAOUASe53e488c2016-08-21 12:19:25 +020073 printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val);
74 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx);
Fabian Kunkel171e2c92016-07-27 17:30:49 +020075
Fabian Kunkel171e2c92016-07-27 17:30:49 +020076 post_code(0x37);
77 AGESAWRAPPER(amdinitreset);
78
79 post_code(0x38);
80 printk(BIOS_DEBUG, "Got past avalon_early_setup\n");
81
82 post_code(0x39);
83 AGESAWRAPPER(amdinitearly);
84 int s3resume = acpi_is_wakeup_s3();
85 if (!s3resume) {
86 post_code(0x40);
87 AGESAWRAPPER(amdinitpost);
88
89 //PspMboxBiosCmdDramInfo();
90 post_code(0x41);
91 AGESAWRAPPER(amdinitenv);
92 /*
93 If code hangs here, please check cahaltasm.S
94 */
95 disable_cache_as_ram();
96 } else { /* S3 detect */
97 printk(BIOS_INFO, "S3 detected\n");
98
99 post_code(0x60);
100 AGESAWRAPPER(amdinitresume);
101
102 AGESAWRAPPER(amds3laterestore);
103
104 post_code(0x61);
105 prepare_for_resume();
106 }
107
108 outb(0xEA, 0xCD6);
109 outb(0x1, 0xcd7);
110
111 post_code(0x50);
112 copy_and_run();
113
114 post_code(0x54); /* Should never see this post code. */
115}