4 #define RAMINIT_SYSINFO 1
5 #define CACHE_AS_RAM_ADDRESS_DEBUG 0
7 #define SET_NB_CFG_54 1
10 #define QRANK_DIMM_SUPPORT 1
12 //used by incoherent_ht
13 //#define K8_SCAN_PCI_BUS 1
14 //#define K8_ALLOCATE_IO_RANGE 1
17 //used by init_cpus and fidvid
18 #define K8_SET_FIDVID 0
19 //if we want to wait for core1 done before DQS training, set it to 0
20 #define K8_SET_FIDVID_CORE0_ONLY 1
22 #if K8_REV_F_SUPPORT == 1
23 #define K8_REV_F_SUPPORT_F0_F1_WORKAROUND 0
27 #include <device/pci_def.h>
28 #include <device/pci_ids.h>
30 #include <device/pnp_def.h>
31 #include <arch/romcc_io.h>
32 #include <cpu/x86/lapic.h>
33 #include "option_table.h"
34 #include "pc80/mc146818rtc_early.c"
36 #if USE_FAILOVER_IMAGE==0
37 #include "pc80/serial.c"
38 #include "arch/i386/lib/console.c"
39 #include <cpu/amd/model_fxx_rev.h>
40 #include "southbridge/amd/amd8111/amd8111_early_smbus.c"
41 #include "northbridge/amd/amdk8/raminit.h"
42 #include "cpu/amd/model_fxx/apic_timer.c"
47 #include "cpu/x86/lapic/boot_cpu.c"
48 #include "northbridge/amd/amdk8/reset_test.c"
50 #if USE_FAILOVER_IMAGE==0
51 #include "cpu/x86/bist.h"
53 #include "lib/delay.c"
55 #if CONFIG_USE_INIT == 0
56 #include "lib/memcpy.c"
57 // TODO: This doesn't compile at the moment. Fix later.
58 // #if CONFIG_USE_PRINTK_IN_CAR == 1
59 // #include "lib/uart8250.c"
60 // #include "console/vtxprintf.c"
61 // #include "arch/i386/lib/printk_init.c"
64 #include "northbridge/amd/amdk8/debug.c"
65 #include "cpu/amd/mtrr/amd_earlymtrr.c"
66 #include "superio/winbond/w83627hf/w83627hf_early_serial.c"
68 #include "northbridge/amd/amdk8/setup_resource_map.c"
70 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
72 #include "southbridge/amd/amd8111/amd8111_early_ctrl.c"
75 * GPIO28 of 8111 will control H0_MEMRESET_L
76 * GPIO29 of 8111 will control H1_MEMRESET_L
78 static void memreset_setup(void)
80 if (is_cpu_pre_c0()) {
81 /* Set the memreset low */
82 outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 28);
83 /* Ensure the BIOS has control of the memory lines */
84 outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 29);
86 /* Ensure the CPU has controll of the memory lines */
87 outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(1<<0), SMBUS_IO_BASE + 0xc0 + 29);
91 static void memreset(int controllers, const struct mem_controller *ctrl)
93 if (is_cpu_pre_c0()) {
95 /* Set memreset_high */
96 outb((0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(1<<0), SMBUS_IO_BASE + 0xc0 + 28);
101 static inline void activate_spd_rom(const struct mem_controller *ctrl)
105 static inline int spd_read_byte(unsigned device, unsigned address)
107 return smbus_read_byte(device, address);
110 #include "northbridge/amd/amdk8/amdk8.h"
111 #include "northbridge/amd/amdk8/coherent_ht_car.c"
113 #include "northbridge/amd/amdk8/incoherent_ht.c"
115 #include "northbridge/amd/amdk8/raminit.c"
117 #include "sdram/generic_sdram.c"
118 #include "ram/ramtest.c"
120 /* tyan does not want the default */
121 #include "resourcemap.c"
123 #include "cpu/amd/dualcore/dualcore.c"
135 #include "cpu/amd/car/copy_and_run.c"
136 #include "cpu/amd/car/post_cache_as_ram.c"
138 #include "cpu/amd/model_fxx/init_cpus.c"
140 #include "cpu/amd/model_fxx/fidvid.c"
143 #if ((HAVE_FAILOVER_BOOT==1) && (USE_FAILOVER_IMAGE == 1)) || ((HAVE_FAILOVER_BOOT==0) && (USE_FALLBACK_IMAGE == 1))
145 #include "southbridge/amd/amd8111/amd8111_enable_rom.c"
146 #include "northbridge/amd/amdk8/early_ht.c"
148 void failover_process(unsigned long bist, unsigned long cpu_init_detectedx)
151 unsigned last_boot_normal_x = last_boot_normal();
153 /* Is this a cpu only reset? or Is this a secondary cpu? */
154 if ((cpu_init_detectedx) || (!boot_cpu())) {
155 if (last_boot_normal_x) {
162 /* Nothing special needs to be done to find bus 0 */
163 /* Allow the HT devices to be found */
165 enumerate_ht_chain();
167 /* Setup the rom access for 4M */
168 amd8111_enable_rom();
170 /* Is this a deliberate reset by the bios */
171 if (bios_reset_detected() && last_boot_normal_x) {
174 /* This is the primary cpu how should I boot? */
175 else if (do_normal_boot()) {
182 __asm__ volatile ("jmp __normal_image"
184 : "a" (bist), "b" (cpu_init_detectedx) /* inputs */
188 #if HAVE_FAILOVER_BOOT==1
189 __asm__ volatile ("jmp __fallback_image"
191 : "a" (bist), "b" (cpu_init_detectedx) /* inputs */
198 void real_main(unsigned long bist, unsigned long cpu_init_detectedx);
200 void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
202 #if HAVE_FAILOVER_BOOT==1
203 #if USE_FAILOVER_IMAGE==1
204 failover_process(bist, cpu_init_detectedx);
206 real_main(bist, cpu_init_detectedx);
209 #if USE_FALLBACK_IMAGE == 1
210 failover_process(bist, cpu_init_detectedx);
212 real_main(bist, cpu_init_detectedx);
216 #if USE_FAILOVER_IMAGE==0
218 void real_main(unsigned long bist, unsigned long cpu_init_detectedx)
220 static const uint16_t spd_addr[] = {
224 #if CONFIG_MAX_PHYSICAL_CPUS > 1
232 struct sys_info *sysinfo = (DCACHE_RAM_BASE + DCACHE_RAM_SIZE - DCACHE_RAM_GLOBAL_VAR_SIZE);
234 int needs_reset; int i;
235 unsigned bsp_apicid = 0;
238 bsp_apicid = init_cpus(cpu_init_detectedx, sysinfo);
241 w83627hf_enable_serial(SERIAL_DEV, TTYS0_BASE);
245 /* Halt if there was a built in self test failure */
246 report_bist_failure(bist);
248 print_debug("*sysinfo range: ["); print_debug_hex32(sysinfo); print_debug(","); print_debug_hex32((unsigned long)sysinfo+sizeof(struct sys_info)); print_debug(")\r\n");
250 setup_mb_resource_map();
252 print_debug("bsp_apicid="); print_debug_hex8(bsp_apicid); print_debug("\r\n");
254 #if MEM_TRAIN_SEQ == 1
255 set_sysinfo_in_ram(0); // in BSP so could hold all ap until sysinfo is in ram
257 setup_coherent_ht_domain(); // routing table and start other core0
259 wait_all_core0_started();
260 #if CONFIG_LOGICAL_CPUS==1
261 // It is said that we should start core1 after all core0 launched
262 /* becase optimize_link_coherent_ht is moved out from setup_coherent_ht_domain,
263 * So here need to make sure last core0 is started, esp for two way system,
264 * (there may be apic id conflicts in that case)
267 wait_all_other_cores_started(bsp_apicid);
270 /* it will set up chains and store link pair for optimization later */
271 ht_setup_chains_x(sysinfo); // it will init sblnk and sbbusn, nodes, sbdn
274 #if K8_SET_FIDVID == 1
278 msr=rdmsr(0xc0010042);
279 print_debug("begin msr fid, vid "); print_debug_hex32( msr.hi ); print_debug_hex32(msr.lo); print_debug("\r\n");
285 enable_fid_change_on_sb(sysinfo->sbbusn, sysinfo->sbdn);
287 init_fidvid_bsp(bsp_apicid);
289 // show final fid and vid
292 msr=rdmsr(0xc0010042);
293 print_debug("end msr fid, vid "); print_debug_hex32( msr.hi ); print_debug_hex32(msr.lo); print_debug("\r\n");
298 needs_reset = optimize_link_coherent_ht();
299 needs_reset |= optimize_link_incoherent_ht(sysinfo);
301 // fidvid change will issue one LDTSTOP and the HT change will be effective too
303 print_info("ht reset -\r\n");
304 soft_reset_x(sysinfo->sbbusn, sysinfo->sbdn);
307 allow_all_aps_stop(bsp_apicid);
309 //It's the time to set ctrl in sysinfo now;
310 fill_mem_ctrl(sysinfo->nodes, sysinfo->ctrl, spd_addr);
315 dump_smbus_registers();
320 //do we need apci timer, tsc...., only debug need it for better output
321 /* all ap stopped? */
322 init_timer(); // Need to use TMICT to synconize FID/VID
323 sdram_initialize(sysinfo->nodes, sysinfo->ctrl, sysinfo);
330 post_cache_as_ram(); // bsp swtich stack to ram and copy sysinfo ram now