2 * This file is part of the LinuxBIOS 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 version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <device/pci_def.h>
26 #include <device/pnp_def.h>
27 #include <arch/romcc_io.h>
29 #include "pc80/serial.c"
30 #include "arch/i386/lib/console.c"
31 #include "ram/ramtest.c"
32 #include "cpu/x86/bist.h"
33 #include "cpu/x86/msr.h"
34 #include <cpu/amd/lxdef.h>
35 #include <cpu/amd/geode_post_code.h>
36 #include "southbridge/amd/cs5536/cs5536.h"
38 #define POST_CODE(x) outb(x, 0x80)
39 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
41 /* The alix1c has no SMBUS; the setup is hard-wired. */
42 void cs5536_enable_smbus(void)
46 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
47 #include "superio/winbond/w83627hf/w83627hf_early_serial.c"
49 /* the part is a hynix hy5du121622ctp-d43
50 * HY 5D U 12 16 2 2 C <blank> T <blank> P D43
53 * VDD 2.5 VDDQ 2.5 (U)
54 * 512M 8K REFRESH (12)
59 * Normal Power Consumption (<blank> )
61 * Single Die (<blank>)
66 static u8 spdbytes[] = {
67 [SPD_ACCEPTABLE_CAS_LATENCIES] = 0x10,
68 [SPD_BANK_DENSITY] = 0x40,
69 [SPD_DEVICE_ATTRIBUTES_GENERAL] = 0xff,
70 [SPD_MEMORY_TYPE] = 7,
71 [SPD_MIN_CYCLE_TIME_AT_CAS_MAX] = 10, /* This is a guess for tRAC value */
72 [SPD_MODULE_ATTRIBUTES] = 0xff, /* fix me later when we figure out */
73 [SPD_NUM_BANKS_PER_SDRAM] = 4,
74 [SPD_PRIMARY_SDRAM_WIDTH] = 8,
75 /* alix1c is 1 bank. */
76 [SPD_NUM_DIMM_BANKS] = 1,
77 [SPD_NUM_COLUMNS] = 0xa,
80 [SPD_SDRAM_CYCLE_TIME_2ND] = 60,
81 [SPD_SDRAM_CYCLE_TIME_3RD] = 75,
89 static u8 spd_read_byte(unsigned device, unsigned address)
91 print_debug("spd_read_byte dev ");
92 print_debug_hex8(device);
94 if (device != (0x50<<1)){
95 print_debug(" returns 0xff\n");
99 print_debug(" addr ");
100 print_debug_hex8(address);
101 print_debug(" returns ");
102 print_debug_hex8(spdbytes[address]);
104 return spdbytes[address];
107 #define ManualConf 0 /* Do automatic strapped PLL config */
108 #define PLLMSRhi 0x00001490 /* manual settings for the PLL */
109 #define PLLMSRlo 0x02000030
112 #include "northbridge/amd/lx/raminit.h"
113 #include "northbridge/amd/lx/pll_reset.c"
114 #include "northbridge/amd/lx/raminit.c"
115 #include "sdram/generic_sdram.c"
116 #include "cpu/amd/model_lx/cpureginit.c"
117 #include "cpu/amd/model_lx/syspreinit.c"
119 static void msr_init(void)
122 /* Setup access to the MC for under 1MB. Note MC not setup yet. */
125 wrmsr(CPU_RCONF_DEFAULT, msr);
129 wrmsr(MSR_GLIU0 + 0x20, msr);
133 wrmsr(MSR_GLIU1 + 0x20, msr);
137 static void mb_gpio_init(void)
139 /* Early mainboard specific GPIO setup */
142 void cache_as_ram_main(void)
144 static const struct mem_controller memctrl[] = {
145 {.channel0 = {0x50}},
147 extern void RestartCAR();
153 cs5536_early_setup();
155 /* NOTE: must do this AFTER the early_setup!
156 * it is counting on some early MSR setup
159 cs5536_disable_internal_uart();
160 w83627hf_enable_serial(SERIAL_DEV, TTYS0_BASE);
165 pll_reset(ManualConf);
169 sdram_initialize(1, memctrl);
172 ram_check(0x00000000, 640 * 1024);
174 /* Switch from Cache as RAM to real RAM
175 * There are two ways we could think about this.
177 * 1. If we are using the auto.inc ROMCC way, the stack is
178 * going to be re-setup in the code following this code. Just
179 * wbinvd the stack to clear the cache tags. We don't care
180 * where the stack used to be.
182 * 2. This file is built as a normal .c -> .o and linked in
183 * etc. The stack might be used to return etc. That means we
184 * care about what is in the stack. If we are smart we set
185 * the CAR stack to the same location as the rest of
186 * LinuxBIOS. If that is the case we can just do a wbinvd.
187 * The stack will be written into real RAM that is now setup
188 * and we continue like nothing happened. If the stack is
189 * located somewhere other than where LB would like it, you
190 * need to write some code to do a copy from cache to RAM
192 * We use method 1 on Norwich and on this board too.
195 print_err("POST 02\n");
197 print_err("Past wbinvd\n");
198 /* we are finding the return does not work on this
199 * board. Explicitly call the label that is after the call to
200 * us. This is gross, but sometimes at this level it is the
203 done_cache_as_ram_main();