This drops the ASSEMBLY define from romstage.c, too
[coreboot.git] / src / mainboard / amd / norwich / romstage.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 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; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #include <stdint.h>
22 #include <device/pci_def.h>
23 #include <arch/io.h>
24 #include <device/pnp_def.h>
25 #include <arch/hlt.h>
26 #include "pc80/serial.c"
27 #include "arch/i386/lib/console.c"
28 #include "lib/ramtest.c"
29 #include "cpu/x86/bist.h"
30 #include "cpu/x86/msr.h"
31 #include <cpu/amd/lxdef.h>
32 #include <cpu/amd/geode_post_code.h>
33 #include "southbridge/amd/cs5536/cs5536.h"
34
35 #define POST_CODE(x) outb(x, 0x80)
36
37 #include "southbridge/amd/cs5536/cs5536_early_smbus.c"
38 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
39
40 static inline int spd_read_byte(unsigned int device, unsigned int address)
41 {
42         return smbus_read_byte(device, address);
43 }
44
45 #define ManualConf 0            /* Do automatic strapped PLL config */
46 #define PLLMSRhi 0x00001490     /* manual settings for the PLL */
47 #define PLLMSRlo 0x02000030
48 #define DIMM0 0xA0
49 #define DIMM1 0xA2
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
58 static void msr_init(void)
59 {
60         msr_t msr;
61
62         /* Setup access to the cache for under 1MB. */
63         msr.hi = 0x24fffc02;
64         msr.lo = 0x1000A000;    /* 0-A0000 write back */
65         wrmsr(CPU_RCONF_DEFAULT, msr);
66
67         msr.hi = 0x0;           /* write back */
68         msr.lo = 0x0;
69         wrmsr(CPU_RCONF_A0_BF, msr);
70         wrmsr(CPU_RCONF_C0_DF, msr);
71         wrmsr(CPU_RCONF_E0_FF, msr);
72
73         /* Setup access to the cache for under 640K. Note MC not setup yet. */
74         msr.hi = 0x20000000;
75         msr.lo = 0xfff80;
76         wrmsr(MSR_GLIU0 + 0x20, msr);
77
78         msr.hi = 0x20000000;
79         msr.lo = 0x80fffe0;
80         wrmsr(MSR_GLIU0 + 0x21, msr);
81
82         msr.hi = 0x20000000;
83         msr.lo = 0xfff80;
84         wrmsr(MSR_GLIU1 + 0x20, msr);
85
86         msr.hi = 0x20000000;
87         msr.lo = 0x80fffe0;
88         wrmsr(MSR_GLIU1 + 0x21, msr);
89 }
90
91 static void mb_gpio_init(void)
92 {
93         /* Early mainboard specific GPIO setup. */
94 }
95
96 void cache_as_ram_main(void)
97 {
98         POST_CODE(0x01);
99
100         static const struct mem_controller memctrl[] = {
101                 {.channel0 = {(0xa << 3) | 0, (0xa << 3) | 1}}
102         };
103
104         SystemPreInit();
105         msr_init();
106
107         cs5536_early_setup();
108
109         /* Note: must do this AFTER the early_setup! It is counting on some
110          * early MSR setup for CS5536.
111          */
112         /* cs5536_disable_internal_uart: disable them for now, set them
113          * up later...
114          */
115         /* If debug. real setup done in chipset init via Config.lb. */
116         cs5536_setup_onchipuart(1);
117         mb_gpio_init();
118         uart_init();
119         console_init();
120
121         pll_reset(ManualConf);
122
123         cpuRegInit();
124
125         sdram_initialize(1, memctrl);
126
127         /* Check memory. */
128         /* ram_check(0x00000000, 640 * 1024); */
129
130         /* Memory is setup. Return to cache_as_ram.inc and continue to boot. */
131         return;
132 }
133