4 #define K8_4RANK_DIMM_SUPPORT 1
6 #if CONFIG_LOGICAL_CPUS==1
7 #define SET_NB_CFG_54 1
11 #include <device/pci_def.h>
13 #include <device/pnp_def.h>
14 #include <arch/romcc_io.h>
15 #include <cpu/x86/lapic.h>
16 #include "option_table.h"
17 #include "pc80/mc146818rtc_early.c"
18 #include "pc80/serial.c"
19 #include "arch/i386/lib/console.c"
20 #include "ram/ramtest.c"
22 #include <cpu/amd/model_fxx_rev.h>
23 #include "northbridge/amd/amdk8/incoherent_ht.c"
24 #include "southbridge/amd/amd8111/amd8111_early_smbus.c"
25 #include "northbridge/amd/amdk8/raminit.h"
26 #include "cpu/amd/model_fxx/apic_timer.c"
27 #include "lib/delay.c"
29 #if CONFIG_USE_INIT == 0
30 #include "lib/memcpy.c"
33 #include "cpu/x86/lapic/boot_cpu.c"
34 #include "northbridge/amd/amdk8/reset_test.c"
35 #include "northbridge/amd/amdk8/debug.c"
36 #include "superio/winbond/w83627hf/w83627hf_early_serial.c"
38 #include "cpu/amd/mtrr/amd_earlymtrr.c"
39 #include "cpu/x86/bist.h"
41 #include "northbridge/amd/amdk8/setup_resource_map.c"
43 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
45 static void hard_reset(void)
50 dev = PCI_DEV(node_link_to_bus(0, 2), 0x04, 3);
55 pci_write_config8(dev, 0x41, 0xf1);
60 static void soft_reset(void)
65 dev = PCI_DEV(node_link_to_bus(0, 2), 0x04, 0);
68 pci_write_config8(dev, 0x47, 1);
71 static void memreset_setup(void)
73 if (is_cpu_pre_c0()) {
74 outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 16); //REVC_MEMRST_EN=0
77 outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(1<<0), SMBUS_IO_BASE + 0xc0 + 16); //REVC_MEMRST_EN=1
79 outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 17);
82 static void memreset(int controllers, const struct mem_controller *ctrl)
84 if (is_cpu_pre_c0()) {
86 outb((0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(1<<0), SMBUS_IO_BASE + 0xc0 + 17); //REVB_MEMRST_L=1
91 static inline void activate_spd_rom(const struct mem_controller *ctrl)
96 static inline int spd_read_byte(unsigned device, unsigned address)
98 return smbus_read_byte(device, address);
102 #include "northbridge/amd/amdk8/raminit.c"
103 #include "resourcemap.c"
104 #include "northbridge/amd/amdk8/coherent_ht.c"
105 #include "sdram/generic_sdram.c"
107 #include "cpu/amd/dualcore/dualcore.c"
110 #include "cpu/amd/car/copy_and_run.c"
112 #include "cpu/amd/car/post_cache_as_ram.c"
114 #include "cpu/amd/model_fxx/init_cpus.c"
117 #if USE_FALLBACK_IMAGE == 1
119 #include "southbridge/amd/amd8111/amd8111_enable_rom.c"
120 #include "northbridge/amd/amdk8/early_ht.c"
122 void failover_process(unsigned long bist, unsigned long cpu_init_detectedx)
124 unsigned last_boot_normal_x = last_boot_normal();
126 /* Is this a cpu only reset? or Is this a secondary cpu? */
127 if ((cpu_init_detectedx) || (!boot_cpu())) {
128 if (last_boot_normal_x) {
135 /* Nothing special needs to be done to find bus 0 */
136 /* Allow the HT devices to be found */
138 enumerate_ht_chain();
140 amd8111_enable_rom();
142 /* Is this a deliberate reset by the bios */
143 if (bios_reset_detected() && last_boot_normal_x) {
146 /* This is the primary cpu how should I boot? */
147 else if (do_normal_boot()) {
154 __asm__ volatile ("jmp __normal_image"
156 : "a" (bist), "b" (cpu_init_detectedx) /* inputs */
164 void real_main(unsigned long bist, unsigned long cpu_init_detectedx);
166 void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
169 #if USE_FALLBACK_IMAGE == 1
170 failover_process(bist, cpu_init_detectedx);
172 real_main(bist, cpu_init_detectedx);
176 void real_main(unsigned long bist, unsigned long cpu_init_detectedx)
178 static const uint16_t spd_addr [] = {
179 (0xa<<3)|0, (0xa<<3)|2, 0, 0,
180 (0xa<<3)|1, (0xa<<3)|3, 0, 0,
181 #if CONFIG_MAX_PHYSICAL_CPUS > 1
182 (0xa<<3)|4, (0xa<<3)|6, 0, 0,
183 (0xa<<3)|5, (0xa<<3)|7, 0, 0,
188 unsigned cpu_reset = 0;
189 unsigned bsp_apicid = 0;
191 struct mem_controller ctrl[8];
195 bsp_apicid = init_cpus(cpu_init_detectedx);
199 w83627hf_enable_serial(SERIAL_DEV, TTYS0_BASE);
203 /* Halt if there was a built in self test failure */
204 report_bist_failure(bist);
206 setup_s2881_resource_map();
208 needs_reset = setup_coherent_ht_domain();
210 #if CONFIG_LOGICAL_CPUS==1
211 // It is said that we should start core1 after all core0 launched
212 wait_all_core0_started();
216 wait_all_aps_started(bsp_apicid);
218 needs_reset |= ht_setup_chains_x();
221 print_info("ht reset -\r\n");
227 allow_all_aps_stop(bsp_apicid);
230 //It's the time to set ctrl now;
231 fill_mem_ctrl(nodes, ctrl, spd_addr);
234 sdram_initialize(nodes, ctrl);
237 post_cache_as_ram(cpu_reset);