Clean up AMD romstage.c serial output
[coreboot.git] / src / mainboard / asrock / e350m1 / romstage.c
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
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
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>
27 #include <arch/romcc_io.h>
28 #include <arch/cpu.h>
29 #include <cpu/x86/lapic.h>
30 #include <console/console.h>
31 #include <console/loglevel.h>
32 #include "agesawrapper.h"
33 #include "cpu/x86/bist.h"
34 #include "superio/winbond/w83627hf/early_serial.c"
35 #include "cpu/x86/lapic/boot_cpu.c"
36 #include "pc80/i8254.c"
37 #include "pc80/i8259.c"
38 #include "sb_cimx.h"
39 #include "SBPLATFORM.h"
40
41 void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx);
42
43 #define SERIAL_DEV PNP_DEV(CONFIG_SIO_PORT, W83627HF_SP1)
44
45 void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
46 {
47         u32 val;
48         u8 reg8;
49
50         /*
51          * All cores: allow caching of flash chip code and data
52          * (there are no cache-as-ram reliability concerns with family 14h)
53          */
54         __writemsr(0x20c, (0x0100000000ull - CONFIG_ROM_SIZE) | 5);
55         __writemsr(0x20d, (0x1000000000ull - CONFIG_ROM_SIZE) | 0x800);
56
57         /* All cores: set pstate 0 (1600 MHz) early to save a few ms of boot time */
58         __writemsr(0xc0010062, 0);
59
60         if (!cpu_init_detectedx && boot_cpu()) {
61                 post_code(0x30);
62                 sb_Poweron_Init();
63
64                 post_code(0x31);
65                 w83627hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
66                 console_init();
67         }
68
69         /* Halt if there was a built in self test failure */
70         post_code(0x34);
71         report_bist_failure(bist);
72
73         /* Load MPB */
74         val = cpuid_eax(1);
75         printk(BIOS_DEBUG, "BSP Family_Model: %08x \n", val);
76         printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx \n", cpu_init_detectedx);
77
78         post_code(0x35);
79         printk(BIOS_DEBUG, "agesawrapper_amdinitmmio ");
80         val = agesawrapper_amdinitmmio();
81         if (val)
82                 printk(BIOS_DEBUG, "error level: %x \n", val);
83         else
84                 printk(BIOS_DEBUG, "passed.\n");
85
86         post_code(0x37);
87         printk(BIOS_DEBUG, "agesawrapper_amdinitreset ");
88         val = agesawrapper_amdinitreset();
89         if (val)
90                 printk(BIOS_DEBUG, "error level: %x \n", val);
91         else
92                 printk(BIOS_DEBUG, "passed.\n");
93
94         post_code(0x39);
95         printk(BIOS_DEBUG, "agesawrapper_amdinitearly ");
96         val = agesawrapper_amdinitearly();
97         if (val)
98                 printk(BIOS_DEBUG, "error level: %x \n", val);
99         else
100                 printk(BIOS_DEBUG, "passed.\n");
101
102         post_code(0x40);
103         printk(BIOS_DEBUG, "agesawrapper_amdinitpost ");
104         val = agesawrapper_amdinitpost();
105         if (val)
106                 printk(BIOS_DEBUG, "error level: %x \n", val);
107         else
108                 printk(BIOS_DEBUG, "passed.\n");
109
110         post_code(0x41);
111         printk(BIOS_DEBUG, "agesawrapper_amdinitenv ");
112         val = agesawrapper_amdinitenv();
113         if (val)
114                 printk(BIOS_DEBUG, "error level: %x \n", val);
115         else
116                 printk(BIOS_DEBUG, "passed.\n");
117
118         /* Initialize i8259 pic */
119         post_code(0x41);
120         setup_i8259();
121
122         /* Initialize i8254 timers */
123         post_code(0x42);
124         setup_i8254();
125
126         post_code(0x50);
127         copy_and_run(0);
128         printk(BIOS_ERR, "Error: copy_and_run() returned!\n");
129
130         post_code(0x54);        /* Should never see this post code. */
131 }