This patch drops arch/i386/lib/console.c and arch/i386/lib/console_print.c and
[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 "pc80/serial.c"
29 #include "console/console.c"
30 #include "lib/ramtest.c"
31 #include "cpu/x86/bist.h"
32 #include "cpu/x86/msr.h"
33 #include <cpu/amd/lxdef.h>
34 #include <cpu/amd/geode_post_code.h>
35 #include "southbridge/amd/cs5536/cs5536.h"
36 #include "spd_table.h"
37
38 #define POST_CODE(x) outb(x, 0x80)
39
40 #include "southbridge/amd/cs5536/cs5536_early_smbus.c"
41 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
42
43 #define DIMM0 0xA0
44 #define DIMM1 0xA2
45
46 static int spd_read_byte(unsigned device, unsigned address)
47 {
48         int i;
49
50         if (device == DIMM0){
51                 for (i=0; i < (ARRAY_SIZE(spd_table)); i++){
52                         if (spd_table[i].address == address){
53                                 return spd_table[i].data;
54                         }
55                 }
56         }
57
58         /* returns 0xFF on any failures */
59         return 0xFF;
60 }
61
62 #define ManualConf 0            /* Do automatic strapped PLL config */
63 /* CPU and GLIU mult/div 500/266*/
64 #define PLLMSRhi 0x0000039C /* 33MHz PCI, 0x000003DD for 66MHz PCI */
65 /* Hold Count - how long we will sit in reset */
66 #define PLLMSRlo 0x00DE6000
67
68 #include "northbridge/amd/lx/raminit.h"
69 #include "northbridge/amd/lx/pll_reset.c"
70 #include "northbridge/amd/lx/raminit.c"
71 #include "lib/generic_sdram.c"
72 #include "cpu/amd/model_lx/cpureginit.c"
73 #include "cpu/amd/model_lx/syspreinit.c"
74
75 static void msr_init(void)
76 {
77         msr_t msr;
78         /* Setup access to the cache for under 1MB. */
79         msr.hi = 0x24fffc02;
80         msr.lo = 0x1000A000;    /* 0-A0000 write back */
81         wrmsr(CPU_RCONF_DEFAULT, msr);
82
83         msr.hi = 0x0;           /* write back */
84         msr.lo = 0x0;
85         wrmsr(CPU_RCONF_A0_BF, msr);
86         wrmsr(CPU_RCONF_C0_DF, msr);
87         wrmsr(CPU_RCONF_E0_FF, msr);
88
89         /* Setup access to the cache for under 640K. Note MC not setup yet. */
90         msr.hi = 0x20000000;
91         msr.lo = 0xfff80;
92         wrmsr(MSR_GLIU0 + 0x20, msr);
93
94         msr.hi = 0x20000000;
95         msr.lo = 0x80fffe0;
96         wrmsr(MSR_GLIU0 + 0x21, msr);
97
98         msr.hi = 0x20000000;
99         msr.lo = 0xfff80;
100         wrmsr(MSR_GLIU1 + 0x20, msr);
101
102         msr.hi = 0x20000000;
103         msr.lo = 0x80fffe0;
104         wrmsr(MSR_GLIU1 + 0x21, msr);
105
106 }
107
108 static void mb_gpio_init(void)
109 {
110         /* Early mainboard specific GPIO setup */
111 }
112
113 void cache_as_ram_main(void)
114 {
115         POST_CODE(0x01);
116
117         static const struct mem_controller memctrl[] = {
118                 {.channel0 = {(0xa << 3) | 0, (0xa << 3) | 1}}
119         };
120
121         SystemPreInit();
122         msr_init();
123
124         cs5536_early_setup();
125
126         /* NOTE: must do this AFTER the early_setup!
127          * it is counting on some early MSR setup
128          * for cs5536
129          */
130         /* cs5536_disable_internal_uart  disable them. Set them up now... */
131         cs5536_setup_onchipuart(2); /* dbe61 uses UART2 as COM1 */
132         mb_gpio_init();
133         uart_init();
134         console_init();
135
136         pll_reset(ManualConf);
137
138         cpuRegInit();
139
140         sdram_initialize(1, memctrl);
141
142         /* Dump memory configuratation */
143         /*{
144         msr_t msr;
145         msr = rdmsr(MC_CF07_DATA);
146         print_debug("MC_CF07_DATA: ");
147         print_debug_hex32(MC_CF07_DATA);
148         print_debug(" value is: ");
149         print_debug_hex32(msr.hi);
150         print_debug(":");
151         print_debug_hex32(msr.lo);
152         print_debug(" \n");
153
154         msr = rdmsr(MC_CF1017_DATA);
155         print_debug("MC_CF1017_DATA: ");
156         print_debug_hex32(MC_CF1017_DATA);
157         print_debug(" value is: ");
158         print_debug_hex32(msr.hi);
159         print_debug(":");
160         print_debug_hex32(msr.lo);
161         print_debug(" \n");
162
163         msr = rdmsr(MC_CF8F_DATA);
164         print_debug("MC_CF8F_DATA: ");
165         print_debug_hex32(MC_CF8F_DATA);
166         print_debug(" value is: ");
167         print_debug_hex32(msr.hi);
168         print_debug(":");
169         print_debug_hex32(msr.lo);
170         msr = rdmsr(MC_CF8F_DATA);
171         print_debug(" \n");
172         }*/
173
174         /* Check memory. */
175         /* ram_check(0x00000000, 640 * 1024); */
176
177         /* Memory is setup. Return to cache_as_ram.inc and continue to boot */
178         return;
179 }
180