blob: 522336068619b2e06e2ce568db800949b63897b3 [file] [log] [blame]
Scott Duplichana649a962011-02-24 05:00:33 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 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
Paul Menzela46a7122013-02-23 18:37:27 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Scott Duplichana649a962011-02-24 05:00:33 +000018 */
19
20#include <stdint.h>
21#include <string.h>
22#include <device/pci_def.h>
23#include <device/pci_ids.h>
24#include <arch/io.h>
25#include <arch/stages.h>
26#include <device/pnp_def.h>
Scott Duplichana649a962011-02-24 05:00:33 +000027#include <arch/cpu.h>
28#include <cpu/x86/lapic.h>
29#include <console/console.h>
30#include <console/loglevel.h>
Kyösti Mälkki107f72e2014-01-06 11:06:26 +020031#include <cpu/x86/mtrr.h>
Kyösti Mälkki2458f422014-04-22 16:46:31 +030032#include "cpu/amd/car.h"
Scott Duplichana649a962011-02-24 05:00:33 +000033#include "agesawrapper.h"
Kyösti Mälkki7b23ae02014-07-04 16:14:37 +030034#include <northbridge/amd/agesa/agesawrapper_call.h>
Scott Duplichana649a962011-02-24 05:00:33 +000035#include "cpu/x86/bist.h"
Edward O'Callaghandbbc1362014-04-28 02:07:32 +100036#include <superio/winbond/common/winbond.h>
37#include <superio/winbond/w83627hf/w83627hf.h>
Kyösti Mälkkic66f1cb2013-08-12 16:09:00 +030038#include "cpu/x86/lapic.h"
Paul Menzel69743962013-04-19 10:05:57 +020039#include <sb_cimx.h>
Scott Duplichana649a962011-02-24 05:00:33 +000040#include "SBPLATFORM.h"
41
Scott Duplichana649a962011-02-24 05:00:33 +000042
Edward O'Callaghanc94d73e2014-06-16 17:24:14 +100043#define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
Scott Duplichana649a962011-02-24 05:00:33 +000044
45void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
46{
Stefan Reinauer44c1d312011-06-04 10:36:21 -070047 u32 val;
Scott Duplichana649a962011-02-24 05:00:33 +000048
Marc Jones938ae3e2012-01-17 16:51:24 -070049 /*
50 * All cores: allow caching of flash chip code and data
51 * (there are no cache-as-ram reliability concerns with family 14h)
52 */
Kyösti Mälkki107f72e2014-01-06 11:06:26 +020053 __writemsr(0x20c, (0x0100000000ull - CACHE_ROM_SIZE) | 5);
54 __writemsr(0x20d, (0x1000000000ull - CACHE_ROM_SIZE) | 0x800);
Marshall Buschman314f4a22011-06-04 15:47:05 +000055
Marc Jones938ae3e2012-01-17 16:51:24 -070056 /* All cores: set pstate 0 (1600 MHz) early to save a few ms of boot time */
Stefan Reinauer44c1d312011-06-04 10:36:21 -070057 __writemsr(0xc0010062, 0);
Marshall Buschmanfd460e62011-06-04 15:44:54 +000058
Stefan Reinauer44c1d312011-06-04 10:36:21 -070059 if (!cpu_init_detectedx && boot_cpu()) {
60 post_code(0x30);
Kerry Shefeed3292011-08-18 18:03:44 +080061 sb_Poweron_Init();
Marshall Buschmanb3ee0d62011-06-04 15:44:31 +000062
Stefan Reinauer44c1d312011-06-04 10:36:21 -070063 post_code(0x31);
Edward O'Callaghandbbc1362014-04-28 02:07:32 +100064 winbond_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
Stefan Reinauer44c1d312011-06-04 10:36:21 -070065 console_init();
66 }
Scott Duplichana649a962011-02-24 05:00:33 +000067
Stefan Reinauer44c1d312011-06-04 10:36:21 -070068 /* Halt if there was a built in self test failure */
69 post_code(0x34);
70 report_bist_failure(bist);
Scott Duplichana649a962011-02-24 05:00:33 +000071
Marc Jones938ae3e2012-01-17 16:51:24 -070072 /* Load MPB */
Stefan Reinauer44c1d312011-06-04 10:36:21 -070073 val = cpuid_eax(1);
Elyes HAOUASaedcc102014-07-21 08:07:19 +020074 printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val);
75 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx);
Scott Duplichana649a962011-02-24 05:00:33 +000076
Stefan Reinauer44c1d312011-06-04 10:36:21 -070077 post_code(0x35);
Kyösti Mälkki7b23ae02014-07-04 16:14:37 +030078 AGESAWRAPPER(amdinitmmio);
Scott Duplichana649a962011-02-24 05:00:33 +000079
Stefan Reinauer44c1d312011-06-04 10:36:21 -070080 post_code(0x37);
Kyösti Mälkki7b23ae02014-07-04 16:14:37 +030081 AGESAWRAPPER(amdinitreset);
Scott Duplichana649a962011-02-24 05:00:33 +000082
Stefan Reinauer44c1d312011-06-04 10:36:21 -070083 post_code(0x39);
Kyösti Mälkki7b23ae02014-07-04 16:14:37 +030084 AGESAWRAPPER(amdinitearly);
Scott Duplichana649a962011-02-24 05:00:33 +000085
Stefan Reinauer44c1d312011-06-04 10:36:21 -070086 post_code(0x40);
Kyösti Mälkki7b23ae02014-07-04 16:14:37 +030087 AGESAWRAPPER(amdinitpost);
Scott Duplichana649a962011-02-24 05:00:33 +000088
Stefan Reinauer44c1d312011-06-04 10:36:21 -070089 post_code(0x41);
Kyösti Mälkki7b23ae02014-07-04 16:14:37 +030090 AGESAWRAPPER(amdinitenv);
Scott Duplichana649a962011-02-24 05:00:33 +000091
Stefan Reinauer44c1d312011-06-04 10:36:21 -070092 post_code(0x50);
Stefan Reinauer648d1662013-05-06 18:05:39 -070093 copy_and_run();
Marc Jones938ae3e2012-01-17 16:51:24 -070094 printk(BIOS_ERR, "Error: copy_and_run() returned!\n");
Scott Duplichana649a962011-02-24 05:00:33 +000095
Marc Jones938ae3e2012-01-17 16:51:24 -070096 post_code(0x54); /* Should never see this post code. */
Scott Duplichana649a962011-02-24 05:00:33 +000097}