blob: 1a32abf2095206ddcc4115e9d4caa3fdfedb5bad [file] [log] [blame]
efdesign9895b66112011-07-20 13:23:04 -06001/*
2 * This file is part of the coreboot project.
3 *
Kerry Sheha3f06072012-02-07 20:32:38 +08004 * Copyright (C) 2011 - 2012 Advanced Micro Devices, Inc.
efdesign9895b66112011-07-20 13:23:04 -06005 *
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.
efdesign9895b66112011-07-20 13:23:04 -060014 */
15
16#include <lib.h>
17#include <reset.h>
18#include <stdint.h>
19#include <arch/io.h>
efdesign9895b66112011-07-20 13:23:04 -060020#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>
Kerry Sheha3f06072012-02-07 20:32: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>
efdesign9895b66112011-07-20 13:23:04 -060033
Edward O'Callaghanc94d73e2014-06-16 17:24:14 +100034/* though UARTs are on the NUVOTON BMC, port 0x164E
35 * PS2 keyboard and mouse are on SUPERIO_WINBOND_W83627DHG, port 0x2E
36 */
37#define SIO_PORT 0x164e
efdesign9895b66112011-07-20 13:23:04 -060038
39void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
40{
41 u32 val;
42
Kerry Sheha3f06072012-02-07 20:32:38 +080043 post_code(0x30);
Kyösti Mälkki48518f02014-11-25 14:20:57 +020044 amd_initmmio();
Kerry Sheha3f06072012-02-07 20:32:38 +080045 post_code(0x31);
efdesign9895b66112011-07-20 13:23:04 -060046
47 /* Halt if there was a built in self test failure */
48 post_code(0x33);
49 report_bist_failure(bist);
50
efdesign9895b66112011-07-20 13:23:04 -060051 sb7xx_51xx_enable_wideio(0, 0x1600); /* though UARTs are on the NUVOTON BMC */
Edward O'Callaghanc94d73e2014-06-16 17:24:14 +100052 wpcm450_enable_dev(WPCM450_SP1, SIO_PORT, CONFIG_TTYS0_BASE);
efdesign9895b66112011-07-20 13:23:04 -060053 sb7xx_51xx_disable_wideio(0);
54 post_code(0x34);
55
efdesign9895b66112011-07-20 13:23:04 -060056 post_code(0x35);
57 console_init();
58
59 val = cpuid_eax(1);
Elyes HAOUASaedcc102014-07-21 08:07:19 +020060 printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val);
61 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx);
efdesign9895b66112011-07-20 13:23:04 -060062
63 post_code(0x37);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030064 agesawrapper_amdinitreset();
efdesign9895b66112011-07-20 13:23:04 -060065
Kerry Sheha3f06072012-02-07 20:32:38 +080066 if (!cpu_init_detectedx && boot_cpu()) {
67 post_code(0x38);
68 /*
69 * SR5650/5670/5690 RD890 chipset, read pci config space hang at POR,
70 * Disable all Pcie Bridges to work around It.
71 */
72 sr56x0_rd890_disable_pcie_bridge();
73 post_code(0x39);
74 nb_Poweron_Init();
75 post_code(0x3A);
76 sb_Poweron_Init();
77 }
78 post_code(0x3B);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030079 agesawrapper_amdinitearly();
efdesign9895b66112011-07-20 13:23:04 -060080
Kerry Sheha3f06072012-02-07 20:32:38 +080081 post_code(0x3C);
Kerry Sheh134d8a92012-02-07 20:33:21 +080082 /* W83627DHG pin89,90 function select is RSTOUT3#, RSTOUT2# by default.
83 * In order to access W83795G/ADG HWM using I2C protocol,
84 * we select function to SDA, SCL function (or GP33, GP32 function).
85 */
86 w83627dhg_enable_i2c(PNP_DEV(0x2E, W83627DHG_SPI));
87
Kerry Sheha3f06072012-02-07 20:32:38 +080088 nb_Ht_Init();
89 post_code(0x3D);
90 /* Reset for HT, FIDVID, PLL and ucode patch(errata) changes to take affect. */
efdesign9895b66112011-07-20 13:23:04 -060091 if (!warm_reset_detect(0)) {
Stefan Reinauer069f4762015-01-05 13:02:32 -080092 printk(BIOS_INFO, "...WARM RESET...\n\n\n");
efdesign9895b66112011-07-20 13:23:04 -060093 distinguish_cpu_resets(0);
94 soft_reset();
95 die("After soft_reset_x - shouldn't see this message!!!\n");
96 }
97
98 post_code(0x40);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +030099 agesawrapper_amdinitpost();
efdesign9895b66112011-07-20 13:23:04 -0600100
101 post_code(0x41);
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +0300102 agesawrapper_amdinitenv();
efdesign9895b66112011-07-20 13:23:04 -0600103 post_code(0x42);
efdesign9895b66112011-07-20 13:23:04 -0600104
105 post_code(0x50);
Stefan Reinauer069f4762015-01-05 13:02:32 -0800106 printk(BIOS_DEBUG, "Disabling cache as ram ");
efdesign9895b66112011-07-20 13:23:04 -0600107 disable_cache_as_ram();
Stefan Reinauer069f4762015-01-05 13:02:32 -0800108 printk(BIOS_DEBUG, "done\n");
efdesign9895b66112011-07-20 13:23:04 -0600109
110 post_code(0x51);
Stefan Reinauer648d1662013-05-06 18:05:39 -0700111 copy_and_run();
efdesign9895b66112011-07-20 13:23:04 -0600112
113 /* We will not return, Should never see this message and post code. */
Stefan Reinauer069f4762015-01-05 13:02:32 -0800114 printk(BIOS_DEBUG, "should not be here -\n");
efdesign9895b66112011-07-20 13:23:04 -0600115 post_code(0x54);
116}