blob: 071f2477db240c34ab0deba5443c7f75317a3356 [file] [log] [blame]
Siyuan Wang8ff97b22012-10-28 18:19:38 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 - 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.
Siyuan Wang8ff97b22012-10-28 18:19:38 +080014 */
15
16#include <lib.h>
17#include <reset.h>
18#include <stdint.h>
19#include <arch/io.h>
Siyuan Wang8ff97b22012-10-28 18:19:38 +080020#include <arch/cpu.h>
21#include <console/console.h>
22#include <arch/stages.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110023#include <cpu/x86/bist.h>
24#include <cpu/x86/lapic.h>
Edward O'Callaghanbf9d1222014-10-29 09:26:00 +110025#include <cpu/amd/car.h>
Kyösti Mälkkif21c2ac2014-10-19 09:35:18 +030026#include <northbridge/amd/agesa/agesawrapper.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110027#include <northbridge/amd/agesa/family10/reset_test.h>
Siyuan Wang8ff97b22012-10-28 18:19:38 +080028#include <nb_cimx.h>
29#include <sb_cimx.h>
Edward O'Callaghan74834e02015-01-04 04:17:35 +110030#include <superio/nuvoton/wpcm450/wpcm450.h>
Edward O'Callaghanffe460d2014-04-27 22:51:40 +100031#include <superio/winbond/common/winbond.h>
32#include <superio/winbond/w83627dhg/w83627dhg.h>
Siyuan Wang8ff97b22012-10-28 18:19:38 +080033
Siyuan Wang8ff97b22012-10-28 18:19:38 +080034
35#define SERIAL_DEV PNP_DEV(0x2e, W83627DHG_SP1)
36#define DUMMY_DEV PNP_DEV(0x2e, 0)
37
38void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
39{
40 u32 val;
41
42 post_code(0x30);
Kyösti Mälkki48518f02014-11-25 14:20:57 +020043 amd_initmmio();
Siyuan Wang8ff97b22012-10-28 18:19:38 +080044 post_code(0x31);
45
46 /* Halt if there was a built in self test failure */
47 post_code(0x33);
48 report_bist_failure(bist);
49
50 sb7xx_51xx_enable_wideio(0, 0x1600); /* though UARTs are on the NUVOTON BMC */
51 wpcm450_enable_dev(WPCM450_SP1, 0x164E, CONFIG_TTYS0_BASE);
52 sb7xx_51xx_disable_wideio(0);
53 post_code(0x34);
54
Siyuan Wang8ff97b22012-10-28 18:19:38 +080055 post_code(0x35);
56 console_init();
57
58 val = cpuid_eax(1);
Elyes HAOUASaedcc102014-07-21 08:07:19 +020059 printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val);
60 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx);
Siyuan Wang8ff97b22012-10-28 18:19:38 +080061
62 post_code(0x37);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030063 agesawrapper_amdinitreset();
Siyuan Wang8ff97b22012-10-28 18:19:38 +080064
65 if (!cpu_init_detectedx && boot_cpu()) {
66 post_code(0x38);
67 /*
68 * SR5650/5670/5690 RD890 chipset, read pci config space hang at POR,
69 * Disable all Pcie Bridges to work around It.
70 */
71 sr56x0_rd890_disable_pcie_bridge();
72 post_code(0x39);
73 nb_Poweron_Init();
74 post_code(0x3A);
75 sb_Poweron_Init();
76 }
77 post_code(0x3B);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030078 agesawrapper_amdinitearly();
Siyuan Wang8ff97b22012-10-28 18:19:38 +080079
80 post_code(0x3C);
81 nb_Ht_Init();
82
83 post_code(0x3D);
84 /* Reset for HT, FIDVID, PLL and ucode patch(errata) changes to take affect. */
85 if (!warm_reset_detect(0)) {
Stefan Reinauer069f4762015-01-05 13:02:32 -080086 printk(BIOS_INFO, "...WARM RESET...\n\n\n");
Siyuan Wang8ff97b22012-10-28 18:19:38 +080087 distinguish_cpu_resets(0);
88 soft_reset();
89 die("After soft_reset_x - shouldn't see this message!!!\n");
90 }
91
92 post_code(0x40);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030093 agesawrapper_amdinitpost();
Siyuan Wang8ff97b22012-10-28 18:19:38 +080094
95 post_code(0x41);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030096 agesawrapper_amdinitenv();
Siyuan Wang8ff97b22012-10-28 18:19:38 +080097 post_code(0x42);
98
Siyuan Wang8ff97b22012-10-28 18:19:38 +080099 post_code(0x50);
Stefan Reinauer069f4762015-01-05 13:02:32 -0800100 printk(BIOS_DEBUG, "Disabling cache as ram ");
Siyuan Wang8ff97b22012-10-28 18:19:38 +0800101 disable_cache_as_ram();
Stefan Reinauer069f4762015-01-05 13:02:32 -0800102 printk(BIOS_DEBUG, "done\n");
Siyuan Wang8ff97b22012-10-28 18:19:38 +0800103
104 post_code(0x51);
Stefan Reinauer648d1662013-05-06 18:05:39 -0700105 copy_and_run();
Siyuan Wang8ff97b22012-10-28 18:19:38 +0800106
107 /* We will not return, Should never see this message and post code. */
Stefan Reinauer069f4762015-01-05 13:02:32 -0800108 printk(BIOS_DEBUG, "should not be here -\n");
Siyuan Wang8ff97b22012-10-28 18:19:38 +0800109 post_code(0x54);
110}