This patch adds support for the AMD Norwich development platform
[coreboot.git] / src / mainboard / amd / norwich / cache_as_ram_auto.c
1 /*
2 *
3 * Copyright (C) 2007 Advanced Micro Devices
4 *
5 */
6
7 #define ASSEMBLY 1
8
9 #include <stdint.h>
10 #include <device/pci_def.h>
11 #include <arch/io.h>
12 #include <device/pnp_def.h>
13 #include <arch/romcc_io.h>
14 #include <arch/hlt.h>
15 #include "pc80/serial.c"
16 #include "arch/i386/lib/console.c"
17 #include "ram/ramtest.c"
18 #include "cpu/x86/bist.h"
19 #include "cpu/x86/msr.h"
20 #include <cpu/amd/lxdef.h>
21 #include <cpu/amd/geode_post_code.h>
22 #include "southbridge/amd/cs5536/cs5536.h"
23
24 #define POST_CODE(x) outb(x, 0x80)
25
26 #include "southbridge/amd/cs5536/cs5536_early_smbus.c"
27 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
28
29 static inline int spd_read_byte(unsigned device, unsigned address)
30 {
31                 return smbus_read_byte(device, address);
32 }
33
34 #define ManualConf 0            /* Do automatic strapped PLL config */
35 #define PLLMSRhi 0x00001490 /* manual settings for the PLL */
36 #define PLLMSRlo 0x02000030
37 #define DIMM0 0xA0
38 #define DIMM1 0xA2
39 #include "northbridge/amd/lx/raminit.h"
40 #include "northbridge/amd/lx/pll_reset.c"
41 #include "northbridge/amd/lx/raminit.c"
42 #include "sdram/generic_sdram.c"
43 #include "cpu/amd/model_lx/cpureginit.c"
44 #include "cpu/amd/model_lx/syspreinit.c"
45
46 static void msr_init(void)
47 {
48         msr_t msr;
49         /* Setup access to the cache for under 1MB. */
50         msr.hi = 0x24fffc02;
51         msr.lo =  0x1000A000; /* 0-A0000 write back */
52         wrmsr(CPU_RCONF_DEFAULT, msr);
53
54         msr.hi = 0x0;   /* write back */
55         msr.lo =  0x0;
56         wrmsr(CPU_RCONF_A0_BF, msr);
57         wrmsr(CPU_RCONF_C0_DF, msr);
58         wrmsr(CPU_RCONF_E0_FF, msr);
59
60         /* Setup access to the cache for under 640K. Note MC not setup yet. */
61         msr.hi = 0x20000000;
62         msr.lo = 0xfff80;
63         wrmsr(MSR_GLIU0 + 0x20, msr);
64
65         msr.hi = 0x20000000;
66         msr.lo = 0x80fffe0;
67         wrmsr(MSR_GLIU0 + 0x21, msr);
68
69         msr.hi = 0x20000000;
70         msr.lo =  0xfff80;
71         wrmsr(MSR_GLIU1 + 0x20, msr);
72
73         msr.hi = 0x20000000;
74         msr.lo =  0x80fffe0;
75         wrmsr(MSR_GLIU1 + 0x21, msr);
76
77 }
78
79 static void mb_gpio_init(void)
80 {
81         /* Early mainboard specific GPIO setup */
82 }
83
84 void cache_as_ram_main(void)
85 {
86         POST_CODE(0x01);
87
88         static const struct mem_controller memctrl [] = {
89                 {.channel0 = {(0xa<<3)|0, (0xa<<3)|1}}
90         };
91
92         SystemPreInit();
93         msr_init();
94
95         cs5536_early_setup();
96
97         /* NOTE: must do this AFTER the early_setup!
98          * it is counting on some early MSR setup
99          * for cs5536
100          */
101         /* cs5536_disable_internal_uart  disable them for now, set them up later...*/
102         cs5536_setup_onchipuart(); /* if debug. real setup done in chipset init via config.lb */
103         mb_gpio_init();
104         uart_init();
105         console_init();
106
107         pll_reset(ManualConf);
108
109         cpuRegInit();
110
111         sdram_initialize(1, memctrl);
112
113         /* Check all of memory */
114         /*ram_check(0x00000000, 640*1024);*/
115
116         /* Memory is setup. Return to cache_as_ram.inc and continue to boot */
117         return;
118 }