copy_and_run: drop boot_complete parameter
[gnutoo-for-coreboot:coreboot.git] / src / mainboard / supermicro / h8scm / romstage.c
1 /*
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.
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
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19
20 #include <lib.h>
21 #include <reset.h>
22 #include <stdint.h>
23 #include <arch/io.h>
24 #include <arch/cpu.h>
25 #include <console/console.h>
26 #include <arch/stages.h>
27 #include "cpu/x86/bist.h"
28 #include "cpu/x86/lapic/boot_cpu.c"
29 #include "agesawrapper.h"
30 #include "northbridge/amd/agesa/family10/reset_test.h"
31 #include <nb_cimx.h>
32 #include <sb_cimx.h>
33 #include "src/drivers/pc80/i8254.c"
34 #include "src/drivers/pc80/i8259.c"
35 #include "superio/nuvoton/wpcm450/wpcm450.h"
36 #include "superio/winbond/w83627dhg/w83627dhg.h"
37
38 extern void disable_cache_as_ram(void); /* cache_as_ram.inc */
39
40 #define SERIAL_DEV PNP_DEV(0x2e, W83627DHG_SP1)
41 #define DUMMY_DEV PNP_DEV(0x2e, 0)
42
43 void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
44 {
45         u32 val;
46
47         post_code(0x30);
48         agesawrapper_amdinitmmio();
49         post_code(0x31);
50
51         /* Halt if there was a built in self test failure */
52         post_code(0x33);
53         report_bist_failure(bist);
54
55         sb7xx_51xx_enable_wideio(0, 0x1600); /* though UARTs are on the NUVOTON BMC */
56         wpcm450_enable_dev(WPCM450_SP1, 0x164E, CONFIG_TTYS0_BASE);
57         sb7xx_51xx_disable_wideio(0);
58         post_code(0x34);
59
60         uart_init();
61         post_code(0x35);
62         console_init();
63
64         val = cpuid_eax(1);
65         printk(BIOS_DEBUG, "BSP Family_Model: %08x \n", val);
66         printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx \n", cpu_init_detectedx);
67
68         post_code(0x37);
69         val = agesawrapper_amdinitreset();
70         if (val) {
71                 printk(BIOS_DEBUG, "agesawrapper_amdinitreset failed: %x \n", val);
72         } else {
73                 printk(BIOS_DEBUG, "agesawrapper_amdinitreset passed\n");
74         }
75
76         if (!cpu_init_detectedx && boot_cpu()) {
77                 post_code(0x38);
78                 /*
79                  * SR5650/5670/5690 RD890 chipset, read pci config space hang at POR,
80                  * Disable all Pcie Bridges to work around It.
81                  */
82                 sr56x0_rd890_disable_pcie_bridge();
83                 post_code(0x39);
84                 nb_Poweron_Init();
85                 post_code(0x3A);
86                 sb_Poweron_Init();
87         }
88         post_code(0x3B);
89         val = agesawrapper_amdinitearly();
90         if(val) {
91                 printk(BIOS_DEBUG, "agesawrapper_amdinitearly failed: %x \n", val);
92         } else {
93                 printk(BIOS_DEBUG, "agesawrapper_amdinitearly passed\n");
94         }
95
96         post_code(0x3C);
97         nb_Ht_Init();
98
99         post_code(0x3D);
100         /* Reset for HT, FIDVID, PLL and ucode patch(errata) changes to take affect. */
101         if (!warm_reset_detect(0)) {
102                 print_info("...WARM RESET...\n\n\n");
103                 distinguish_cpu_resets(0);
104                 soft_reset();
105                 die("After soft_reset_x - shouldn't see this message!!!\n");
106         }
107
108         post_code(0x40);
109         val = agesawrapper_amdinitpost();
110         if (val) {
111                 printk(BIOS_DEBUG, "agesawrapper_amdinitpost failed: %x \n", val);
112         } else {
113                 printk(BIOS_DEBUG, "agesawrapper_amdinitpost passed\n");
114         }
115
116         post_code(0x41);
117         val = agesawrapper_amdinitenv();
118         if(val) {
119                 printk(BIOS_DEBUG, "agesawrapper_amdinitenv failed: %x \n", val);
120         }
121         printk(BIOS_DEBUG, "agesawrapper_amdinitenv passed\n");
122
123         post_code(0x42);
124
125         /* Initialize i8259 pic */
126         post_code(0x41);
127         setup_i8259 ();
128
129         /* Initialize i8254 timers */
130         post_code(0x42);
131         setup_i8254 ();
132
133         post_code(0x50);
134         print_debug("Disabling cache as ram ");
135         disable_cache_as_ram();
136         print_debug("done\n");
137
138         post_code(0x51);
139         copy_and_run();
140
141         /* We will not return,  Should never see this message and post code. */
142         print_debug("should not be here -\n");
143         post_code(0x54);
144 }
145