Simplify a few code chunks, fix whitespace and indentation.
[coreboot.git] / src / mainboard / winent / pl6064 / romstage.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 Advanced Micro Devices, Inc.
5  * Copyright (C) 2010 Win Enterprises, Inc (anishp@win-ent.com)
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20  */
21
22 #include <stdint.h>
23 #include <stdlib.h>
24 #include <device/pci_def.h>
25 #include <arch/io.h>
26 #include <device/pnp_def.h>
27 #include <arch/hlt.h>
28 #include <console/console.h>
29 #include <lib.h>
30 #include "cpu/x86/bist.h"
31 #include "cpu/x86/msr.h"
32 #include <cpu/amd/lxdef.h>
33 #include <cpu/amd/geode_post_code.h>
34 #include "southbridge/amd/cs5536/cs5536.h"
35 #include <spd.h>
36 #include "southbridge/amd/cs5536/cs5536_early_smbus.c"
37 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
38 #include "superio/winbond/w83627hf/w83627hf_early_serial.c"
39
40 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
41
42 static inline int spd_read_byte(unsigned int device, unsigned int address)
43 {
44         return smbus_read_byte(device, address);
45 }
46
47 #define ManualConf 0            /* Do automatic strapped PLL config */
48 #define PLLMSRhi 0x00001490     /* Manual settings for the PLL */
49 #define PLLMSRlo 0x02000030
50
51 #include "northbridge/amd/lx/raminit.h"
52 #include "northbridge/amd/lx/pll_reset.c"
53 #include "northbridge/amd/lx/raminit.c"
54 #include "lib/generic_sdram.c"
55 #include "cpu/amd/model_lx/cpureginit.c"
56 #include "cpu/amd/model_lx/syspreinit.c"
57 #include "cpu/amd/model_lx/msrinit.c"
58
59 void main(unsigned long bist)
60 {
61         post_code(0x01);
62
63         static const struct mem_controller memctrl[] = {
64                 {.channel0 = {DIMM0, DIMM1}}
65         };
66
67         SystemPreInit();
68         msr_init();
69
70         cs5536_early_setup();
71
72         /* Note: must do this AFTER the early_setup! It is counting on some
73          * early MSR setup for CS5536.
74          */
75         w83627hf_set_clksel_48(SERIAL_DEV);
76         w83627hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
77         uart_init();
78         console_init();
79
80         /* Halt if there was a built in self test failure */
81         report_bist_failure(bist);
82
83         pll_reset(ManualConf);
84
85         cpuRegInit(0, DIMM0, DIMM1, DRAM_TERMINATED);
86
87         sdram_initialize(1, memctrl);
88
89         /* Check memory. */
90         /* ram_check(0x00000000, 640 * 1024); */
91
92         /* Memory is setup. Return to cache_as_ram.inc and continue to boot. */
93         return;
94 }