3 #include <device/pci_def.h>
4 #include <device/pci_ids.h>
6 #include <device/pnp_def.h>
7 #include <pc80/mc146818rtc.h>
8 #include <console/console.h>
9 #include <cpu/amd/model_fxx_rev.h>
10 #include "southbridge/amd/amd8111/early_smbus.c"
11 #include <northbridge/amd/amdk8/raminit.h>
12 #include "northbridge/amd/amdk8/reset_test.c"
13 #include <cpu/x86/bist.h>
15 #include "northbridge/amd/amdk8/debug.c"
16 #include <superio/winbond/common/winbond.h>
17 #include <superio/winbond/w83627hf/w83627hf.h>
18 #include "northbridge/amd/amdk8/setup_resource_map.c"
19 #include "southbridge/amd/amd8111/early_ctrl.c"
21 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
24 * GPIO28 of 8111 will control H0_MEMRESET_L
25 * GPIO29 of 8111 will control H1_MEMRESET_L
27 static void memreset_setup(void)
29 if (is_cpu_pre_c0()) {
30 /* Set the memreset low. */
31 outb((1<<2)|(0<<0), SMBUS_IO_BASE
+ 0xc0 + 28);
32 /* Ensure the BIOS has control of the memory lines. */
33 outb((1<<2)|(0<<0), SMBUS_IO_BASE
+ 0xc0 + 29);
35 /* Ensure the CPU has control of the memory lines. */
36 outb((1<<2)|(1<<0), SMBUS_IO_BASE
+ 0xc0 + 29);
40 static void memreset(int controllers
, const struct mem_controller
*ctrl
)
42 if (is_cpu_pre_c0()) {
44 /* Set memreset_high */
45 outb((1<<2)|(1<<0), SMBUS_IO_BASE
+ 0xc0 + 28);
50 static void activate_spd_rom(const struct mem_controller
*ctrl
) { }
52 static inline int spd_read_byte(unsigned device
, unsigned address
)
54 return smbus_read_byte(device
, address
);
57 #include <northbridge/amd/amdk8/amdk8.h>
58 #include "northbridge/amd/amdk8/incoherent_ht.c"
59 #include "northbridge/amd/amdk8/coherent_ht.c"
60 #include "northbridge/amd/amdk8/raminit.c"
61 #include "lib/generic_sdram.c"
62 #include "resourcemap.c"
63 #include "cpu/amd/dualcore/dualcore.c"
65 #include "cpu/amd/model_fxx/init_cpus.c"
66 #include "cpu/amd/model_fxx/fidvid.c"
68 void cache_as_ram_main(unsigned long bist
, unsigned long cpu_init_detectedx
)
70 static const uint16_t spd_addr
[] = {
79 struct sys_info
*sysinfo
= &sysinfo_car
;
81 unsigned bsp_apicid
= 0;
84 bsp_apicid
= init_cpus(cpu_init_detectedx
, sysinfo
);
86 winbond_enable_serial(SERIAL_DEV
, CONFIG_TTYS0_BASE
);
89 /* Halt if there was a built in self test failure */
90 report_bist_failure(bist
);
92 printk(BIOS_DEBUG
, "*sysinfo range: [%p,%p]\n",sysinfo
,sysinfo
+1);
94 setup_mb_resource_map();
96 printk(BIOS_DEBUG
, "bsp_apicid=%02x\n", bsp_apicid
);
98 setup_coherent_ht_domain(); // routing table and start other core0
100 wait_all_core0_started();
101 #if CONFIG_LOGICAL_CPUS
102 // It is said that we should start core1 after all core0 launched
103 /* becase optimize_link_coherent_ht is moved out from setup_coherent_ht_domain,
104 * So here need to make sure last core0 is started, esp for two way system,
105 * (there may be apic id conflicts in that case)
108 wait_all_other_cores_started(bsp_apicid
);
111 /* it will set up chains and store link pair for optimization later */
112 ht_setup_chains_x(sysinfo
); // it will init sblnk and sbbusn, nodes, sbdn
114 #if CONFIG_SET_FIDVID
117 msr
=rdmsr(0xc0010042);
118 printk(BIOS_DEBUG
, "begin msr fid, vid %08x%08x\n", msr
.hi
, msr
.lo
);
121 enable_fid_change_on_sb(sysinfo
->sbbusn
, sysinfo
->sbdn
);
122 init_fidvid_bsp(bsp_apicid
);
123 // show final fid and vid
126 msr
=rdmsr(0xc0010042);
127 printk(BIOS_DEBUG
, "end msr fid, vid %08x%08x\n", msr
.hi
, msr
.lo
);
131 needs_reset
= optimize_link_coherent_ht();
132 needs_reset
|= optimize_link_incoherent_ht(sysinfo
);
134 // fidvid change will issue one LDTSTOP and the HT change will be effective too
136 printk(BIOS_INFO
, "ht reset -\n");
137 soft_reset_x(sysinfo
->sbbusn
, sysinfo
->sbdn
);
140 allow_all_aps_stop(bsp_apicid
);
142 //It's the time to set ctrl in sysinfo now;
143 fill_mem_ctrl(sysinfo
->nodes
, sysinfo
->ctrl
, spd_addr
);
148 dump_smbus_registers();
153 //do we need apci timer, tsc...., only debug need it for better output
154 /* all ap stopped? */
155 init_timer(); // Need to use TMICT to synchronize FID/VID
156 sdram_initialize(sysinfo
->nodes
, sysinfo
->ctrl
, sysinfo
);
162 post_cache_as_ram(); // bsp swtich stack to ram and copy sysinfo ram now