2 * This code is derived from the Tyan s2882 romstage.c
3 * Adapted by Stefan Reinauer <stepan@coresystems.de>
4 * Additional (C) 2007 coresystems GmbH
9 #include <device/pci_def.h>
11 #include <device/pnp_def.h>
12 #include <arch/romcc_io.h>
13 #include <pc80/mc146818rtc.h>
14 #include <console/console.h>
17 #include <cpu/amd/model_fxx_rev.h>
18 #include "northbridge/amd/amdk8/incoherent_ht.c"
19 #include "southbridge/amd/amd8111/early_smbus.c"
20 #include "northbridge/amd/amdk8/raminit.h"
21 #include "cpu/amd/model_fxx/apic_timer.c"
22 #include "lib/delay.c"
23 #include "northbridge/amd/amdk8/reset_test.c"
24 #include "northbridge/amd/amdk8/debug.c"
25 #include "superio/winbond/w83627hf/early_serial.c"
26 #include "cpu/x86/mtrr/earlymtrr.c"
27 #include "cpu/x86/bist.h"
28 #include "northbridge/amd/amdk8/setup_resource_map.c"
29 #include "southbridge/amd/amd8111/early_ctrl.c"
31 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
33 static void memreset_setup(void)
35 if (is_cpu_pre_c0()) {
36 /* Set the memreset low. */
37 outb((1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 28);
38 /* Ensure the BIOS has control of the memory lines. */
39 outb((1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 29);
41 /* Ensure the CPU has control of the memory lines. */
42 outb((1<<2)|(1<<0), SMBUS_IO_BASE + 0xc0 + 29);
46 static void memreset(int controllers, const struct mem_controller *ctrl)
48 if (is_cpu_pre_c0()) {
50 /* Set memreset high. */
51 outb((1<<2)|(1<<0), SMBUS_IO_BASE + 0xc0 + 28);
56 static void activate_spd_rom(const struct mem_controller *ctrl) { }
58 static inline int spd_read_byte(unsigned device, unsigned address)
60 return smbus_read_byte(device, address);
63 #include "northbridge/amd/amdk8/raminit.c"
64 #include "northbridge/amd/amdk8/coherent_ht.c"
65 #include "lib/generic_sdram.c"
66 #include "resourcemap.c"
67 #include "cpu/amd/dualcore/dualcore.c"
68 #include "cpu/amd/car/post_cache_as_ram.c"
69 #include "cpu/amd/model_fxx/init_cpus.c"
71 void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
73 static const uint16_t spd_addr [] = {
76 #if CONFIG_MAX_PHYSICAL_CPUS > 1
83 unsigned bsp_apicid = 0, nodes;
84 struct mem_controller ctrl[8];
87 bsp_apicid = init_cpus(cpu_init_detectedx);
89 w83627hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
92 // dump_mem(CONFIG_DCACHE_RAM_BASE+CONFIG_DCACHE_RAM_SIZE-0x200, CONFIG_DCACHE_RAM_BASE+CONFIG_DCACHE_RAM_SIZE);
94 /* Halt if there was a built in self test failure */
95 report_bist_failure(bist);
97 setup_khepri_resource_map();
99 dump_pci_device(PCI_DEV(0, 0x18, 0));
100 dump_pci_device(PCI_DEV(0, 0x19, 0));
103 needs_reset = setup_coherent_ht_domain();
105 wait_all_core0_started();
106 #if CONFIG_LOGICAL_CPUS==1
107 // It is said that we should start core1 after all core0 launched
109 wait_all_other_cores_started(bsp_apicid);
112 needs_reset |= ht_setup_chains_x();
115 print_info("ht reset -\n");
119 allow_all_aps_stop(bsp_apicid);
122 //It's the time to set ctrl now;
123 fill_mem_ctrl(nodes, ctrl, spd_addr);
128 sdram_initialize(nodes, ctrl);