blob: d8342c917f0d73be92a485bf7ca35ae359f0902f [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>
Fabian Kunkel171e2c92016-07-27 17:30:49 +020020#include <arch/io.h>
21#include <arch/stages.h>
22#include <device/pnp_def.h>
23#include <arch/cpu.h>
24#include <cpu/x86/lapic.h>
25#include <console/console.h>
26#include <commonlib/loglevel.h>
27#include <cpu/amd/car.h>
28#include <northbridge/amd/pi/agesawrapper.h>
29#include <northbridge/amd/pi/agesawrapper_call.h>
30#include <cpu/x86/bist.h>
31#include <cpu/x86/lapic.h>
32#include <southbridge/amd/pi/hudson/hudson.h>
Fabian Kunkelcf051832016-07-27 17:42:39 +020033#include <superio/fintek/common/fintek.h>
34#include <superio/fintek/f81866d/f81866d.h>
35
36#define SERIAL_DEV1 PNP_DEV(0x4e, F81866D_SP1)
Fabian Kunkel171e2c92016-07-27 17:30:49 +020037
38void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
39{
40 u32 val;
41
Kyösti Mälkki187543c2016-11-20 11:03:13 +020042 /* Must come first to enable PCI MMCONF. */
43 amd_initmmio();
44
Fabian Kunkel171e2c92016-07-27 17:30:49 +020045 /*
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
Fabian Kunkel171e2c92016-07-27 17:30:49 +020056 hudson_lpc_port80();
57
58 if (!cpu_init_detectedx && boot_cpu()) {
59 post_code(0x30);
Fabian Kunkelcf051832016-07-27 17:42:39 +020060 fintek_enable_serial(SERIAL_DEV1, CONFIG_TTYS0_BASE);
Fabian Kunkel171e2c92016-07-27 17:30:49 +020061 post_code(0x31);
62 console_init();
63 }
64
65 /* Halt if there was a built in self test failure */
66 post_code(0x34);
67 report_bist_failure(bist);
68
69 /* Load MPB */
70 val = cpuid_eax(1);
Elyes HAOUASe53e488c2016-08-21 12:19:25 +020071 printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val);
72 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx);
Fabian Kunkel171e2c92016-07-27 17:30:49 +020073
Fabian Kunkel171e2c92016-07-27 17:30:49 +020074 post_code(0x37);
75 AGESAWRAPPER(amdinitreset);
76
77 post_code(0x38);
78 printk(BIOS_DEBUG, "Got past avalon_early_setup\n");
79
80 post_code(0x39);
81 AGESAWRAPPER(amdinitearly);
Fabian Kunkel171e2c92016-07-27 17:30:49 +020082
Kyösti Mälkki1b183aa2017-02-26 10:11:21 +020083 post_code(0x40);
84 AGESAWRAPPER(amdinitpost);
Fabian Kunkel171e2c92016-07-27 17:30:49 +020085
Kyösti Mälkki1b183aa2017-02-26 10:11:21 +020086 //PspMboxBiosCmdDramInfo();
87 post_code(0x41);
88 AGESAWRAPPER(amdinitenv);
89 /*
90 If code hangs here, please check cahaltasm.S
91 */
92 disable_cache_as_ram();
Fabian Kunkel171e2c92016-07-27 17:30:49 +020093
94 outb(0xEA, 0xCD6);
95 outb(0x1, 0xcd7);
96
97 post_code(0x50);
98 copy_and_run();
99
100 post_code(0x54); /* Should never see this post code. */
101}