This patch drops arch/i386/lib/console.c and arch/i386/lib/console_print.c and
[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 <device/pci_def.h>
24 #include <arch/io.h>
25 #include <device/pnp_def.h>
26 #include <arch/hlt.h>
27 #include "pc80/serial.c"
28 #include "console/console.c"
29 #include "lib/ramtest.c"
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
36 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
37 #define POST_CODE(x) outb(x, 0x80)
38 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
39
40 #include "southbridge/amd/cs5536/cs5536_early_smbus.c"
41 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
42 #include "superio/winbond/w83627hf/w83627hf_early_serial.c"
43
44 static inline int spd_read_byte(unsigned int device, unsigned int address)
45 {
46         return smbus_read_byte(device, address);
47 }
48
49 #define ManualConf 0            /* Do automatic strapped PLL config */
50 #define PLLMSRhi 0x00001490     /* Manual settings for the PLL */
51 #define PLLMSRlo 0x02000030
52 #define DIMM0 0xA0
53 #define DIMM1 0xA2
54
55 #include "northbridge/amd/lx/raminit.h"
56 #include "northbridge/amd/lx/pll_reset.c"
57 #include "northbridge/amd/lx/raminit.c"
58 #include "lib/generic_sdram.c"
59 #include "cpu/amd/model_lx/cpureginit.c"
60 #include "cpu/amd/model_lx/syspreinit.c"
61
62 struct msrinit {
63             u32 msrnum;
64             msr_t msr;
65       };
66
67 static const struct msrinit msr_table[] = 
68 {
69        {CPU_RCONF_DEFAULT, {.hi = 0x24fffc02,.lo = 0x1000A000}}, /* Setup access to cache under 1MB.
70                                                                   * Rom Properties: Write Serialize, WriteProtect.
71                                                                   * RomBase: 0xFFFC0
72                                                                   * SysTop to RomBase Properties: Write Serialize, Cache Disable.
73                                                                   * SysTop: 0x000A0 
74                                                                   * System Memory Properties:  (Write Back) */
75        {CPU_RCONF_A0_BF,   {.hi = 0x00000000,.lo = 0x00000000}}, /* 0xA0000-0xBFFFF : (Write Back) */
76        {CPU_RCONF_C0_DF,   {.hi = 0x00000000,.lo = 0x00000000}}, /* 0xC0000-0xDFFFF : (Write Back) */
77        {CPU_RCONF_E0_FF,   {.hi = 0x00000000,.lo = 0x00000000}}, /* 0xE0000-0xFFFFF : (Write Back) */
78        
79        /* Setup access to memory under 1MB. Note: VGA hole at 0xA0000-0xBFFFF */
80        {MSR_GLIU0_BASE1,   {.hi = 0x20000000,.lo = 0x000fff80}}, // 0x00000-0x7FFFF
81        {MSR_GLIU0_BASE2,   {.hi = 0x20000000,.lo = 0x080fffe0}}, // 0x80000-0x9FFFF
82        {MSR_GLIU0_SHADOW,  {.hi = 0x2000FFFF,.lo = 0xFFFF0003}}, // 0xC0000-0xFFFFF
83        {MSR_GLIU1_BASE1,   {.hi = 0x20000000,.lo = 0x000fff80}}, // 0x00000-0x7FFFF
84        {MSR_GLIU1_BASE2,   {.hi = 0x20000000,.lo = 0x080fffe0}}, // 0x80000-0x9FFFF
85        {MSR_GLIU1_SHADOW,  {.hi = 0x2000FFFF,.lo = 0xFFFF0003}}, // 0xC0000-0xFFFFF
86 };
87
88 static void msr_init(void)
89 {
90   int i;
91        for (i = 0; i < ARRAY_SIZE(msr_table); i++)
92                            wrmsr(msr_table[i].msrnum, msr_table[i].msr);
93 }
94
95 static void mb_gpio_init(void)
96 {
97         /* Early mainboard specific GPIO setup. */
98 }
99
100 void cache_as_ram_main(void)
101 {
102         POST_CODE(0x01);
103
104         static const struct mem_controller memctrl[] = {
105                 {.channel0 = {(0xa << 3) | 0, (0xa << 3) | 1}}
106         };
107
108         SystemPreInit();
109         msr_init();
110
111         cs5536_early_setup();
112
113         /* Note: must do this AFTER the early_setup! It is counting on some
114          * early MSR setup for CS5536.
115          */
116         w83627hf_set_clksel_48(SERIAL_DEV);
117         w83627hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
118         mb_gpio_init();
119         uart_init();
120         console_init();
121
122         pll_reset(ManualConf);
123
124         cpuRegInit();
125
126         sdram_initialize(1, memctrl);
127
128         /* Check memory. */
129         /* ram_check(0x00000000, 640 * 1024); */
130
131         /* Memory is setup. Return to cache_as_ram.inc and continue to boot. */
132         return;
133 }
134