Add constants for fast path resume copying
[coreboot.git] / src / mainboard / artecgroup / dbe61 / 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/romcc_io.h>
26 #include <arch/hlt.h>
27 #include <stdlib.h>
28 #include <console/console.h>
29 #include "cpu/x86/bist.h"
30 #include "cpu/x86/msr.h"
31 #include <cpu/amd/lxdef.h>
32 #include "southbridge/amd/cs5536/cs5536.h"
33 #include "spd_table.h"
34 #include <spd.h>
35 #include "southbridge/amd/cs5536/early_smbus.c"
36 #include "southbridge/amd/cs5536/early_setup.c"
37
38 static int spd_read_byte(unsigned device, unsigned address)
39 {
40         int i;
41
42         if (device == DIMM0) {
43                 for (i=0; i < (ARRAY_SIZE(spd_table)); i++) {
44                         if (spd_table[i].address == address) {
45                                 return spd_table[i].data;
46                         }
47                 }
48         }
49
50         /* returns 0xFF on any failures */
51         return 0xFF;
52 }
53
54 #define ManualConf 0            /* Do automatic strapped PLL config */
55 /* CPU and GLIU mult/div 500/266*/
56 #define PLLMSRhi 0x0000039C /* 33MHz PCI, 0x000003DD for 66MHz PCI */
57 /* Hold Count - how long we will sit in reset */
58 #define PLLMSRlo 0x00DE6000
59
60 #include "northbridge/amd/lx/raminit.h"
61 #include "northbridge/amd/lx/pll_reset.c"
62 #include "northbridge/amd/lx/raminit.c"
63 #include "lib/generic_sdram.c"
64 #include "cpu/amd/geode_lx/cpureginit.c"
65 #include "cpu/amd/geode_lx/syspreinit.c"
66 #include "cpu/amd/geode_lx/msrinit.c"
67
68 void main(unsigned long bist)
69 {
70
71         msr_t msr;
72         static const struct mem_controller memctrl[] = {
73                 {.channel0 = {DIMM0, DIMM1}}
74         };
75
76         SystemPreInit();
77         msr_init();
78
79         cs5536_early_setup();
80
81         /* NOTE: must do this AFTER the early_setup!
82          * it is counting on some early MSR setup
83          * for cs5536
84          */
85         /* cs5536_disable_internal_uart  disable them. Set them up now... */
86         cs5536_setup_onchipuart(2); /* dbe61 uses UART2 as COM1 */
87         /* set address to 3F8 */
88         msr = rdmsr(MDD_LEG_IO);
89         msr.lo |= 0x7 << 20;
90         wrmsr(MDD_LEG_IO, msr);
91
92         console_init();
93
94         /* Halt if there was a built in self test failure */
95         report_bist_failure(bist);
96
97         pll_reset(ManualConf);
98
99         cpuRegInit(0, DIMM0, DIMM1, DRAM_TERMINATED);
100
101         sdram_initialize(1, memctrl);
102
103         /* Dump memory configuration. */
104 #if 0
105         msr = rdmsr(MC_CF07_DATA);
106         print_debug("MC_CF07_DATA: ");
107         print_debug_hex32(MC_CF07_DATA);
108         print_debug(" value is: ");
109         print_debug_hex32(msr.hi);
110         print_debug(":");
111         print_debug_hex32(msr.lo);
112         print_debug(" \n");
113
114         msr = rdmsr(MC_CF1017_DATA);
115         print_debug("MC_CF1017_DATA: ");
116         print_debug_hex32(MC_CF1017_DATA);
117         print_debug(" value is: ");
118         print_debug_hex32(msr.hi);
119         print_debug(":");
120         print_debug_hex32(msr.lo);
121         print_debug(" \n");
122
123         msr = rdmsr(MC_CF8F_DATA);
124         print_debug("MC_CF8F_DATA: ");
125         print_debug_hex32(MC_CF8F_DATA);
126         print_debug(" value is: ");
127         print_debug_hex32(msr.hi);
128         print_debug(":");
129         print_debug_hex32(msr.lo);
130         msr = rdmsr(MC_CF8F_DATA);
131         print_debug(" \n");
132 #endif
133 }