- get rid of ASM_CONSOLE_LOGLEVEL except in two assembler files.
[coreboot.git] / src / mainboard / digitallogic / msm800sev / romstage.c
1 #include <stdint.h>
2 #include <device/pci_def.h>
3 #include <arch/io.h>
4 #include <device/pnp_def.h>
5 #include <arch/romcc_io.h>
6 #include <arch/hlt.h>
7 #include "pc80/serial.c"
8 #include "console/console.c"
9 #include "lib/ramtest.c"
10 #include "cpu/x86/bist.h"
11 #include "cpu/x86/msr.h"
12 #include <cpu/amd/lxdef.h>
13 #include <cpu/amd/geode_post_code.h>
14 #include "southbridge/amd/cs5536/cs5536.h"
15
16 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
17
18 #include "southbridge/amd/cs5536/cs5536_early_smbus.c"
19 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
20 #include "superio/winbond/w83627hf/w83627hf_early_serial.c"
21
22 static inline int spd_read_byte(unsigned device, unsigned address)
23 {
24                 return smbus_read_byte(device, address);
25 }
26
27 #define ManualConf 0            /* Do automatic strapped PLL config */
28 #define PLLMSRhi 0x00001490 /* manual settings for the PLL */
29 #define PLLMSRlo 0x02000030
30 #define DIMM0 0xA0
31 #define DIMM1 0xA2
32 #include "northbridge/amd/lx/raminit.h"
33 #include "northbridge/amd/lx/pll_reset.c"
34 #include "northbridge/amd/lx/raminit.c"
35 #include "lib/generic_sdram.c"
36 #include "cpu/amd/model_lx/cpureginit.c"
37 #include "cpu/amd/model_lx/syspreinit.c"
38
39 static void msr_init(void)
40 {
41         msr_t msr;
42         /* Setup access to the MC for under 1MB. Note MC not setup yet. */
43         msr.hi = 0x24fffc02;
44         msr.lo =  0x10010000;
45         wrmsr(CPU_RCONF_DEFAULT, msr);
46
47         msr.hi = 0x20000000;
48         msr.lo = 0xfff00;
49         wrmsr(MSR_GLIU0 + 0x20, msr);
50
51         msr.hi = 0x20000000;
52         msr.lo =  0xfff00;
53         wrmsr(MSR_GLIU1 + 0x20, msr);
54
55 }
56
57 static void mb_gpio_init(void)
58 {
59         /* Early mainboard specific GPIO setup */
60 }
61
62 void cache_as_ram_main(void)
63 {
64         extern void RestartCAR();
65         post_code(0x01);
66
67         static const struct mem_controller memctrl [] = {
68                 {.channel0 = {(0xa<<3)|0, (0xa<<3)|1}}
69         };
70
71         SystemPreInit();
72         msr_init();
73
74         cs5536_early_setup();
75
76         /* NOTE: must do this AFTER the early_setup!
77          * it is counting on some early MSR setup
78          * for cs5536
79          */
80         cs5536_disable_internal_uart();
81         w83627hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
82         mb_gpio_init();
83         uart_init();
84         console_init();
85
86         pll_reset(ManualConf);
87
88         cpuRegInit();
89
90         sdram_initialize(1, memctrl);
91
92         /* Check all of memory */
93         ram_check(0x00000000, 640*1024);
94
95         /* Switch from Cache as RAM to real RAM */
96         /* There are two ways we could think about this.
97          1. If we are using the romstage.inc ROMCC way, the stack is going to be re-setup in the code following this code.
98                 Just wbinvd the stack to clear the cache tags. We don't care where the stack used to be.
99          2. This file is built as a normal .c -> .o and linked in etc. The stack might be used to return etc.
100                 That means we care about what is in the stack. If we are smart we set the CAR stack to the same location
101                 as the rest of coreboot. If that is the case we can just do a wbinvd. The stack will be written into real
102                 RAM that is now setup and we continue like nothing happened. If the stack is located somewhere other than
103                 where LB would like it, you need to write some code to do a copy from cache to RAM
104
105          We use method 1 on Norwich.
106         */
107         post_code(0x02);
108         print_err("POST 02\n");
109         __asm__("wbinvd\n");
110         print_err("Past wbinvd\n");
111         /* we are finding the return does not work on this board. Explicitly call the label that is 
112          * after the call to us. This is gross, but sometimes at this level it is the only way out
113          */
114         void done_cache_as_ram_main(void);
115         done_cache_as_ram_main();
116 }
117