2 * This file is part of the coreboot project.
4 * Copyright (C) 2007 Advanced Micro Devices, Inc.
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.
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.
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
25 #include <device/pci_def.h>
27 #include <device/pnp_def.h>
28 #include <arch/romcc_io.h>
31 #include "pc80/serial.c"
32 #include "arch/i386/lib/console.c"
33 #include "lib/ramtest.c"
34 #include "cpu/x86/bist.h"
35 #include "cpu/x86/msr.h"
36 #include <cpu/amd/lxdef.h>
37 #include <cpu/amd/geode_post_code.h>
38 #include "southbridge/amd/cs5536/cs5536.h"
39 #include "spd_table.h"
42 #define POST_CODE(x) outb(x, 0x80)
44 #include "southbridge/amd/cs5536/cs5536_early_smbus.c"
45 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
51 static int spd_read_byte(unsigned device, unsigned address)
56 for (i=0; i < (ARRAY_SIZE(spd_table)); i++){
57 if (spd_table[i].address == address){
58 return spd_table[i].data;
63 /* returns 0xFF on any failures */
67 #define ManualConf 0 /* Do automatic strapped PLL config */
68 /* CPU and GLIU mult/div 500/266*/
69 #define PLLMSRhi 0x0000039C /* 33MHz PCI, 0x000003DD for 66MHz PCI */
70 /* Hold Count - how long we will sit in reset */
71 #define PLLMSRlo 0x00DE6000
73 #include "northbridge/amd/lx/raminit.h"
74 #include "northbridge/amd/lx/pll_reset.c"
75 #include "northbridge/amd/lx/raminit.c"
76 #include "lib/generic_sdram.c"
77 #include "cpu/amd/model_lx/cpureginit.c"
78 #include "cpu/amd/model_lx/syspreinit.c"
80 static void msr_init(void)
83 /* Setup access to the cache for under 1MB. */
85 msr.lo = 0x1000A000; /* 0-A0000 write back */
86 wrmsr(CPU_RCONF_DEFAULT, msr);
88 msr.hi = 0x0; /* write back */
90 wrmsr(CPU_RCONF_A0_BF, msr);
91 wrmsr(CPU_RCONF_C0_DF, msr);
92 wrmsr(CPU_RCONF_E0_FF, msr);
94 /* Setup access to the cache for under 640K. Note MC not setup yet. */
97 wrmsr(MSR_GLIU0 + 0x20, msr);
101 wrmsr(MSR_GLIU0 + 0x21, msr);
105 wrmsr(MSR_GLIU1 + 0x20, msr);
109 wrmsr(MSR_GLIU1 + 0x21, msr);
113 static void mb_gpio_init(void)
115 /* Early mainboard specific GPIO setup */
118 void cache_as_ram_main(void)
122 static const struct mem_controller memctrl[] = {
123 {.channel0 = {(0xa << 3) | 0, (0xa << 3) | 1}}
129 cs5536_early_setup();
131 /* NOTE: must do this AFTER the early_setup!
132 * it is counting on some early MSR setup
135 /* cs5536_disable_internal_uart disable them. Set them up now... */
136 cs5536_setup_onchipuart(2); /* dbe61 uses UART2 as COM1 */
141 pll_reset(ManualConf);
145 sdram_initialize(1, memctrl);
147 /* Dump memory configuratation */
150 msr = rdmsr(MC_CF07_DATA);
151 print_debug("MC_CF07_DATA: ");
152 print_debug_hex32(MC_CF07_DATA);
153 print_debug(" value is: ");
154 print_debug_hex32(msr.hi);
156 print_debug_hex32(msr.lo);
159 msr = rdmsr(MC_CF1017_DATA);
160 print_debug("MC_CF1017_DATA: ");
161 print_debug_hex32(MC_CF1017_DATA);
162 print_debug(" value is: ");
163 print_debug_hex32(msr.hi);
165 print_debug_hex32(msr.lo);
168 msr = rdmsr(MC_CF8F_DATA);
169 print_debug("MC_CF8F_DATA: ");
170 print_debug_hex32(MC_CF8F_DATA);
171 print_debug(" value is: ");
172 print_debug_hex32(msr.hi);
174 print_debug_hex32(msr.lo);
175 msr = rdmsr(MC_CF8F_DATA);
180 /* ram_check(0x00000000, 640 * 1024); */
182 /* Memory is setup. Return to cache_as_ram.inc and continue to boot */