Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 1 | /* |
| 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 Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 18 | */ |
| 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 Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 27 | #include <arch/cpu.h> |
| 28 | #include <cpu/x86/lapic.h> |
| 29 | #include <console/console.h> |
| 30 | #include <console/loglevel.h> |
Kyösti Mälkki | 107f72e | 2014-01-06 11:06:26 +0200 | [diff] [blame] | 31 | #include <cpu/x86/mtrr.h> |
Kyösti Mälkki | 2458f42 | 2014-04-22 16:46:31 +0300 | [diff] [blame] | 32 | #include "cpu/amd/car.h" |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 33 | #include "agesawrapper.h" |
Kyösti Mälkki | 7b23ae0 | 2014-07-04 16:14:37 +0300 | [diff] [blame] | 34 | #include <northbridge/amd/agesa/agesawrapper_call.h> |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 35 | #include "cpu/x86/bist.h" |
Edward O'Callaghan | dbbc136 | 2014-04-28 02:07:32 +1000 | [diff] [blame] | 36 | #include <superio/winbond/common/winbond.h> |
| 37 | #include <superio/winbond/w83627hf/w83627hf.h> |
Kyösti Mälkki | c66f1cb | 2013-08-12 16:09:00 +0300 | [diff] [blame] | 38 | #include "cpu/x86/lapic.h" |
Paul Menzel | 6974396 | 2013-04-19 10:05:57 +0200 | [diff] [blame] | 39 | #include <sb_cimx.h> |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 40 | #include "SBPLATFORM.h" |
| 41 | |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 42 | |
Edward O'Callaghan | c94d73e | 2014-06-16 17:24:14 +1000 | [diff] [blame] | 43 | #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1) |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 44 | |
| 45 | void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx) |
| 46 | { |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 47 | u32 val; |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 48 | |
Marc Jones | 938ae3e | 2012-01-17 16:51:24 -0700 | [diff] [blame] | 49 | /* |
| 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älkki | 107f72e | 2014-01-06 11:06:26 +0200 | [diff] [blame] | 53 | __writemsr(0x20c, (0x0100000000ull - CACHE_ROM_SIZE) | 5); |
| 54 | __writemsr(0x20d, (0x1000000000ull - CACHE_ROM_SIZE) | 0x800); |
Marshall Buschman | 314f4a2 | 2011-06-04 15:47:05 +0000 | [diff] [blame] | 55 | |
Marc Jones | 938ae3e | 2012-01-17 16:51:24 -0700 | [diff] [blame] | 56 | /* All cores: set pstate 0 (1600 MHz) early to save a few ms of boot time */ |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 57 | __writemsr(0xc0010062, 0); |
Marshall Buschman | fd460e6 | 2011-06-04 15:44:54 +0000 | [diff] [blame] | 58 | |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 59 | if (!cpu_init_detectedx && boot_cpu()) { |
| 60 | post_code(0x30); |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 61 | sb_Poweron_Init(); |
Marshall Buschman | b3ee0d6 | 2011-06-04 15:44:31 +0000 | [diff] [blame] | 62 | |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 63 | post_code(0x31); |
Edward O'Callaghan | dbbc136 | 2014-04-28 02:07:32 +1000 | [diff] [blame] | 64 | winbond_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 65 | console_init(); |
| 66 | } |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 67 | |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 68 | /* Halt if there was a built in self test failure */ |
| 69 | post_code(0x34); |
| 70 | report_bist_failure(bist); |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 71 | |
Marc Jones | 938ae3e | 2012-01-17 16:51:24 -0700 | [diff] [blame] | 72 | /* Load MPB */ |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 73 | val = cpuid_eax(1); |
Elyes HAOUAS | aedcc10 | 2014-07-21 08:07:19 +0200 | [diff] [blame^] | 74 | printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val); |
| 75 | printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx); |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 76 | |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 77 | post_code(0x35); |
Kyösti Mälkki | 7b23ae0 | 2014-07-04 16:14:37 +0300 | [diff] [blame] | 78 | AGESAWRAPPER(amdinitmmio); |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 79 | |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 80 | post_code(0x37); |
Kyösti Mälkki | 7b23ae0 | 2014-07-04 16:14:37 +0300 | [diff] [blame] | 81 | AGESAWRAPPER(amdinitreset); |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 82 | |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 83 | post_code(0x39); |
Kyösti Mälkki | 7b23ae0 | 2014-07-04 16:14:37 +0300 | [diff] [blame] | 84 | AGESAWRAPPER(amdinitearly); |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 85 | |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 86 | post_code(0x40); |
Kyösti Mälkki | 7b23ae0 | 2014-07-04 16:14:37 +0300 | [diff] [blame] | 87 | AGESAWRAPPER(amdinitpost); |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 88 | |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 89 | post_code(0x41); |
Kyösti Mälkki | 7b23ae0 | 2014-07-04 16:14:37 +0300 | [diff] [blame] | 90 | AGESAWRAPPER(amdinitenv); |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 91 | |
Stefan Reinauer | 44c1d31 | 2011-06-04 10:36:21 -0700 | [diff] [blame] | 92 | post_code(0x50); |
Stefan Reinauer | 648d166 | 2013-05-06 18:05:39 -0700 | [diff] [blame] | 93 | copy_and_run(); |
Marc Jones | 938ae3e | 2012-01-17 16:51:24 -0700 | [diff] [blame] | 94 | printk(BIOS_ERR, "Error: copy_and_run() returned!\n"); |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 95 | |
Marc Jones | 938ae3e | 2012-01-17 16:51:24 -0700 | [diff] [blame] | 96 | post_code(0x54); /* Should never see this post code. */ |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 97 | } |