blob: 718d2b2c2f65ffdc8245842447babd0afc9ba598 [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>
Kyösti Mälkki107f72e2014-01-06 11:06:26 +020032#include <cpu/x86/mtrr.h>
Kerry Sheh01f7ab92012-01-19 13:18:36 +080033#include "agesawrapper.h"
Frank Vibrans69da1b62011-02-14 19:04:45 +000034#include "cpu/x86/bist.h"
35#include "superio/smsc/kbc1100/kbc1100_early_init.c"
Kyösti Mälkkic66f1cb2013-08-12 16:09:00 +030036#include "cpu/x86/lapic.h"
Stefan Reinauerae5e11d2012-04-27 02:31:28 +020037#include "drivers/pc80/i8254.c"
38#include "drivers/pc80/i8259.c"
Paul Menzel69743962013-04-19 10:05:57 +020039#include <sb_cimx.h>
Frank Vibrans69da1b62011-02-14 19:04:45 +000040#include "SBPLATFORM.h"
Frank Vibrans69da1b62011-02-14 19:04:45 +000041
42void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
43{
Marc Jonesc9ea3272012-01-17 15:41:03 -070044 u32 val;
Frank Vibrans69da1b62011-02-14 19:04:45 +000045
Kerry Sheh01f7ab92012-01-19 13:18:36 +080046 /* all cores: allow caching of flash chip code and data
47 * (there are no cache-as-ram reliability concerns with family 14h)
48 */
Kyösti Mälkki107f72e2014-01-06 11:06:26 +020049 __writemsr (0x20c, (0x0100000000ull - CACHE_ROM_SIZE) | 5);
50 __writemsr (0x20d, (0x1000000000ull - CACHE_ROM_SIZE) | 0x800);
Kerry Sheh01f7ab92012-01-19 13:18:36 +080051
52 /* all cores: set pstate 0 (1600 MHz) early to save a few ms of boot time
53 */
54 __writemsr (0xc0010062, 0);
55
Marc Jonesc9ea3272012-01-17 15:41:03 -070056 if (!cpu_init_detectedx && boot_cpu()) {
57 post_code(0x30);
58 sb_Poweron_Init();
Frank Vibrans69da1b62011-02-14 19:04:45 +000059
Marc Jonesc9ea3272012-01-17 15:41:03 -070060 post_code(0x31);
61 kbc1100_early_init(CONFIG_SIO_PORT);
62 console_init();
63 }
Frank Vibrans69da1b62011-02-14 19:04:45 +000064
Marc Jonesc9ea3272012-01-17 15:41:03 -070065 /* Halt if there was a built in self test failure */
66 post_code(0x34);
67 report_bist_failure(bist);
Frank Vibrans69da1b62011-02-14 19:04:45 +000068
Marc Jones938ae3e2012-01-17 16:51:24 -070069 /* Load MPB */
Marc Jonesc9ea3272012-01-17 15:41:03 -070070 val = cpuid_eax(1);
71 printk(BIOS_DEBUG, "BSP Family_Model: %08x \n", val);
72 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx \n", cpu_init_detectedx);
Frank Vibrans69da1b62011-02-14 19:04:45 +000073
Marc Jonesc9ea3272012-01-17 15:41:03 -070074 post_code(0x35);
Marc Jones938ae3e2012-01-17 16:51:24 -070075 printk(BIOS_DEBUG, "agesawrapper_amdinitmmio ");
Marc Jonesc9ea3272012-01-17 15:41:03 -070076 val = agesawrapper_amdinitmmio();
Marc Jones938ae3e2012-01-17 16:51:24 -070077 if (val)
78 printk(BIOS_DEBUG, "error level: %x \n", val);
79 else
80 printk(BIOS_DEBUG, "passed.\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +000081
Marc Jonesc9ea3272012-01-17 15:41:03 -070082 post_code(0x37);
Marc Jones938ae3e2012-01-17 16:51:24 -070083 printk(BIOS_DEBUG, "agesawrapper_amdinitreset ");
Marc Jonesc9ea3272012-01-17 15:41:03 -070084 val = agesawrapper_amdinitreset();
Marc Jones938ae3e2012-01-17 16:51:24 -070085 if (val)
86 printk(BIOS_DEBUG, "error level: %x \n", val);
87 else
88 printk(BIOS_DEBUG, "passed.\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +000089
Marc Jonesc9ea3272012-01-17 15:41:03 -070090 post_code(0x39);
Marc Jones938ae3e2012-01-17 16:51:24 -070091 printk(BIOS_DEBUG, "agesawrapper_amdinitearly ");
Marc Jonesc9ea3272012-01-17 15:41:03 -070092 val = agesawrapper_amdinitearly();
Marc Jones938ae3e2012-01-17 16:51:24 -070093 if (val)
94 printk(BIOS_DEBUG, "error level: %x \n", val);
95 else
96 printk(BIOS_DEBUG, "passed.\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +000097
Marc Jonesc9ea3272012-01-17 15:41:03 -070098 post_code(0x40);
Marc Jones938ae3e2012-01-17 16:51:24 -070099 printk(BIOS_DEBUG, "agesawrapper_amdinitpost ");
Marc Jonesc9ea3272012-01-17 15:41:03 -0700100 val = agesawrapper_amdinitpost();
Marc Jones938ae3e2012-01-17 16:51:24 -0700101 if (val)
102 printk(BIOS_DEBUG, "error level: %x \n", val);
103 else
104 printk(BIOS_DEBUG, "passed.\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +0000105
Marc Jonesc9ea3272012-01-17 15:41:03 -0700106 post_code(0x41);
Marc Jones938ae3e2012-01-17 16:51:24 -0700107 printk(BIOS_DEBUG, "agesawrapper_amdinitenv ");
Marc Jonesc9ea3272012-01-17 15:41:03 -0700108 val = agesawrapper_amdinitenv();
Marc Jones938ae3e2012-01-17 16:51:24 -0700109 if (val)
110 printk(BIOS_DEBUG, "error level: %x \n", val);
111 else
112 printk(BIOS_DEBUG, "passed.\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +0000113
Marc Jonesc9ea3272012-01-17 15:41:03 -0700114 /* Initialize i8259 pic */
115 post_code(0x41);
116 setup_i8259();
Frank Vibrans69da1b62011-02-14 19:04:45 +0000117
Marc Jonesc9ea3272012-01-17 15:41:03 -0700118 /* Initialize i8254 timers */
119 post_code(0x42);
120 setup_i8254();
Frank Vibrans69da1b62011-02-14 19:04:45 +0000121
Marc Jonesc9ea3272012-01-17 15:41:03 -0700122 post_code(0x50);
Stefan Reinauer648d1662013-05-06 18:05:39 -0700123 copy_and_run();
Marc Jones938ae3e2012-01-17 16:51:24 -0700124 printk(BIOS_ERR, "Error: copy_and_run() returned!\n");
Frank Vibrans69da1b62011-02-14 19:04:45 +0000125
Marc Jones938ae3e2012-01-17 16:51:24 -0700126 post_code(0x54); /* Should never see this post code. */
Frank Vibrans69da1b62011-02-14 19:04:45 +0000127}