blob: 3474d76894c4de4939b7bfc28d44383789362cfa [file] [log] [blame]
Frank Vibrans69da1b62011-02-14 19:04:45 +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
Frank Vibrans69da1b62011-02-14 19:04:45 +000018 */
19
Kerry Sheh01f7ab92012-01-19 13:18:36 +080020#include <lib.h>
Frank Vibrans69da1b62011-02-14 19:04:45 +000021#include <stdint.h>
22#include <string.h>
23#include <device/pci_def.h>
24#include <device/pci_ids.h>
25#include <arch/io.h>
26#include <arch/stages.h>
27#include <device/pnp_def.h>
Kerry Sheh01f7ab92012-01-19 13:18:36 +080028#include <arch/cpu.h>
Frank Vibrans69da1b62011-02-14 19:04:45 +000029#include <cpu/x86/lapic.h>
30#include <console/console.h>
31#include <console/loglevel.h>
Kerry Sheh01f7ab92012-01-19 13:18:36 +080032#include "agesawrapper.h"
Frank Vibrans69da1b62011-02-14 19:04:45 +000033#include "cpu/x86/bist.h"
34#include "superio/smsc/kbc1100/kbc1100_early_init.c"
35#include "cpu/x86/lapic/boot_cpu.c"
Stefan Reinauerae5e11d2012-04-27 02:31:28 +020036#include "drivers/pc80/i8254.c"
37#include "drivers/pc80/i8259.c"
Paul Menzel69743962013-04-19 10:05:57 +020038#include <sb_cimx.h>
Frank Vibrans69da1b62011-02-14 19:04:45 +000039#include "SBPLATFORM.h"
Frank Vibrans69da1b62011-02-14 19:04:45 +000040
41void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
42{
Marc Jonesc9ea3272012-01-17 15:41:03 -070043 u32 val;
Frank Vibrans69da1b62011-02-14 19:04:45 +000044
Kerry Sheh01f7ab92012-01-19 13:18:36 +080045 /* all cores: allow caching of flash chip code and data
46 * (there are no cache-as-ram reliability concerns with family 14h)
47 */
48 __writemsr (0x20c, (0x0100000000ull - CONFIG_ROM_SIZE) | 5);
49 __writemsr (0x20d, (0x1000000000ull - CONFIG_ROM_SIZE) | 0x800);
50
51 /* all cores: set pstate 0 (1600 MHz) early to save a few ms of boot time
52 */
53 __writemsr (0xc0010062, 0);
54
Marc Jonesc9ea3272012-01-17 15:41:03 -070055 if (!cpu_init_detectedx && boot_cpu()) {
56 post_code(0x30);
57 sb_Poweron_Init();
Frank Vibrans69da1b62011-02-14 19:04:45 +000058
Marc Jonesc9ea3272012-01-17 15:41:03 -070059 post_code(0x31);
60 kbc1100_early_init(CONFIG_SIO_PORT);
61 console_init();
62 }
Frank Vibrans69da1b62011-02-14 19:04:45 +000063
Marc Jonesc9ea3272012-01-17 15:41:03 -070064 /* Halt if there was a built in self test failure */
65 post_code(0x34);
66 report_bist_failure(bist);
Frank Vibrans69da1b62011-02-14 19:04:45 +000067
Marc Jones938ae3e2012-01-17 16:51:24 -070068 /* Load MPB */
Marc Jonesc9ea3272012-01-17 15:41:03 -070069 val = cpuid_eax(1);
70 printk(BIOS_DEBUG, "BSP Family_Model: %08x \n", val);
71 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx \n", cpu_init_detectedx);
Frank Vibrans69da1b62011-02-14 19:04:45 +000072
Marc Jonesc9ea3272012-01-17 15:41:03 -070073 post_code(0x35);
Marc Jones938ae3e2012-01-17 16:51:24 -070074 printk(BIOS_DEBUG, "agesawrapper_amdinitmmio ");
Marc Jonesc9ea3272012-01-17 15:41:03 -070075 val = agesawrapper_amdinitmmio();
Marc Jones938ae3e2012-01-17 16:51:24 -070076 if (val)
77 printk(BIOS_DEBUG, "error level: %x \n", val);
78 else
79 printk(BIOS_DEBUG, "passed.\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +000080
Marc Jonesc9ea3272012-01-17 15:41:03 -070081 post_code(0x37);
Marc Jones938ae3e2012-01-17 16:51:24 -070082 printk(BIOS_DEBUG, "agesawrapper_amdinitreset ");
Marc Jonesc9ea3272012-01-17 15:41:03 -070083 val = agesawrapper_amdinitreset();
Marc Jones938ae3e2012-01-17 16:51:24 -070084 if (val)
85 printk(BIOS_DEBUG, "error level: %x \n", val);
86 else
87 printk(BIOS_DEBUG, "passed.\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +000088
Marc Jonesc9ea3272012-01-17 15:41:03 -070089 post_code(0x39);
Marc Jones938ae3e2012-01-17 16:51:24 -070090 printk(BIOS_DEBUG, "agesawrapper_amdinitearly ");
Marc Jonesc9ea3272012-01-17 15:41:03 -070091 val = agesawrapper_amdinitearly();
Marc Jones938ae3e2012-01-17 16:51:24 -070092 if (val)
93 printk(BIOS_DEBUG, "error level: %x \n", val);
94 else
95 printk(BIOS_DEBUG, "passed.\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +000096
Marc Jonesc9ea3272012-01-17 15:41:03 -070097 post_code(0x40);
Marc Jones938ae3e2012-01-17 16:51:24 -070098 printk(BIOS_DEBUG, "agesawrapper_amdinitpost ");
Marc Jonesc9ea3272012-01-17 15:41:03 -070099 val = agesawrapper_amdinitpost();
Marc Jones938ae3e2012-01-17 16:51:24 -0700100 if (val)
101 printk(BIOS_DEBUG, "error level: %x \n", val);
102 else
103 printk(BIOS_DEBUG, "passed.\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +0000104
Marc Jonesc9ea3272012-01-17 15:41:03 -0700105 post_code(0x41);
Marc Jones938ae3e2012-01-17 16:51:24 -0700106 printk(BIOS_DEBUG, "agesawrapper_amdinitenv ");
Marc Jonesc9ea3272012-01-17 15:41:03 -0700107 val = agesawrapper_amdinitenv();
Marc Jones938ae3e2012-01-17 16:51:24 -0700108 if (val)
109 printk(BIOS_DEBUG, "error level: %x \n", val);
110 else
111 printk(BIOS_DEBUG, "passed.\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +0000112
Marc Jonesc9ea3272012-01-17 15:41:03 -0700113 /* Initialize i8259 pic */
114 post_code(0x41);
115 setup_i8259();
Frank Vibrans69da1b62011-02-14 19:04:45 +0000116
Marc Jonesc9ea3272012-01-17 15:41:03 -0700117 /* Initialize i8254 timers */
118 post_code(0x42);
119 setup_i8254();
Frank Vibrans69da1b62011-02-14 19:04:45 +0000120
Marc Jonesc9ea3272012-01-17 15:41:03 -0700121 post_code(0x50);
Stefan Reinauer648d1662013-05-06 18:05:39 -0700122 copy_and_run();
Marc Jones938ae3e2012-01-17 16:51:24 -0700123 printk(BIOS_ERR, "Error: copy_and_run() returned!\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +0000124
Marc Jones938ae3e2012-01-17 16:51:24 -0700125 post_code(0x54); /* Should never see this post code. */
Frank Vibrans69da1b62011-02-14 19:04:45 +0000126}