2 * This file is part of the coreboot project.
4 * Copyright (C) 2006 Tyan
5 * Copyright (C) 2006 AMD
6 * Written by Yinghai Lu <yinghailu@gmail.com> for Tyan and AMD.
8 * Copyright (C) 2007 University of Mannheim
9 * Written by Philipp Degler <pdegler@rumms.uni-mannheim.de> for University of Mannheim
10 * Copyright (C) 2009 University of Heidelberg
11 * Written by Mondrian Nuessle <nuessle@uni-heidelberg.de> for University of Heidelberg
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 #define RAMINIT_SYSINFO 1
30 #define FAM10_SCAN_PCI_BUS 0
31 #define FAM10_ALLOCATE_IO_RANGE 1
33 #define QRANK_DIMM_SUPPORT 1
35 #if CONFIG_LOGICAL_CPUS==1
36 #define SET_NB_CFG_54 1
40 #define SET_FIDVID_CORE_RANGE 0
42 #define DBGP_DEFAULT 7
46 #include <device/pci_def.h>
47 #include <device/pci_ids.h>
49 #include <device/pnp_def.h>
50 #include <arch/romcc_io.h>
51 #include <cpu/x86/lapic.h>
52 #include "option_table.h"
53 #include <console/console.h>
54 #include "lib/ramtest.c"
55 #include <cpu/amd/model_10xxx_rev.h>
56 #include "southbridge/broadcom/bcm5785/bcm5785_early_smbus.c"
57 #include "southbridge/broadcom/bcm5785/bcm5785_enable_rom.c"
58 #include "northbridge/amd/amdfam10/raminit.h"
59 #include "northbridge/amd/amdfam10/amdfam10.h"
61 #include "cpu/amd/model_10xxx/apic_timer.c"
62 #include "lib/delay.c"
63 #include "cpu/x86/lapic/boot_cpu.c"
64 #include "northbridge/amd/amdfam10/reset_test.c"
66 #include "superio/serverengines/pilot/pilot_early_serial.c"
67 #include "superio/serverengines/pilot/pilot_early_init.c"
68 #include "superio/nsc/pc87417/pc87417_early_serial.c"
70 #include "cpu/x86/bist.h"
72 #include "northbridge/amd/amdfam10/debug.c"
74 #include "cpu/x86/mtrr/earlymtrr.c"
76 //#include "northbridge/amd/amdfam10/setup_resource_map.c"
78 #define SERIAL_DEV PNP_DEV(0x2e, PILOT_SP1)
79 #define RTC_DEV PNP_DEV(0x4e, PC87417_RTC)
81 #include "southbridge/broadcom/bcm5785/bcm5785_early_setup.c"
83 static inline void activate_spd_rom(const struct mem_controller *ctrl)
91 outb((val & ~3) | ctrl->spd_switch_addr, 0xcd7);
94 static inline int spd_read_byte(unsigned device, unsigned address)
96 return smbus_read_byte(device, address);
99 #include "northbridge/amd/amdfam10/amdfam10.h"
101 #include "northbridge/amd/amdfam10/raminit_sysinfo_in_ram.c"
102 #include "northbridge/amd/amdfam10/amdfam10_pci.c"
104 #include "cpu/amd/quadcore/quadcore.c"
106 #include "cpu/amd/car/post_cache_as_ram.c"
108 #include "cpu/amd/microcode/microcode.c"
109 #include "cpu/amd/model_10xxx/update_microcode.c"
110 #include "cpu/amd/model_10xxx/init_cpus.c"
112 #include "northbridge/amd/amdfam10/early_ht.c"
114 #include "spd_addr.h"
116 void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
118 struct sys_info *sysinfo = (struct sys_info *)(CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - CONFIG_DCACHE_RAM_GLOBAL_VAR_SIZE);
125 if (!cpu_init_detectedx && boot_cpu()) {
126 /* Nothing special needs to be done to find bus 0 */
127 /* Allow the HT devices to be found */
128 /* mov bsp to bus 0xff when > 8 nodes */
129 set_bsp_node_CHtExtNodeCfgEn();
130 enumerate_ht_chain();
132 /* Setup the rom access for 4M */
133 bcm5785_enable_rom();
134 bcm5785_enable_lpc();
136 pc87417_enable_dev(RTC_DEV);
142 bsp_apicid = init_cpus(cpu_init_detectedx, sysinfo);
145 pilot_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
149 /* Halt if there was a built in self test failure */
150 report_bist_failure(bist);
153 pilot_early_init(SERIAL_DEV); //config port is being taken from SERIAL_DEV
156 printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val);
157 printk(BIOS_DEBUG, "*sysinfo range: [%p,%p]\n",sysinfo,sysinfo+1);
158 printk(BIOS_DEBUG, "bsp_apicid = %02x\n", bsp_apicid);
159 printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx);
161 /* Setup sysinfo defaults */
162 set_sysinfo_in_ram(0);
164 update_microcode(val);
170 amd_ht_init(sysinfo);
173 /* Setup nodes PCI space and start core 0 AP init. */
174 finalize_node_setup(sysinfo);
178 /* wait for all the APs core0 started by finalize_node_setup. */
179 /* FIXME: A bunch of cores are going to start output to serial at once.
180 * It would be nice to fixup prink spinlocks for ROM XIP mode.
181 * I think it could be done by putting the spinlock flag in the cache
182 * of the BSP located right after sysinfo.
185 wait_all_core0_started();
187 #if CONFIG_LOGICAL_CPUS==1
188 /* Core0 on each node is configured. Now setup any additional cores. */
189 printk(BIOS_DEBUG, "start_other_cores()\n");
192 wait_all_other_cores_started(bsp_apicid);
196 msr = rdmsr(0xc0010071);
197 printk(BIOS_DEBUG, "\nBegin FIDVID MSR 0xc0010071 0x%08x 0x%08x\n", msr.hi, msr.lo);
199 /* FIXME: The sb fid change may survive the warm reset and only
200 * need to be done once.*/
202 enable_fid_change_on_sb(sysinfo->sbbusn, sysinfo->sbdn);
206 if (!warm_reset_detect(0)) { // BSP is node 0
207 init_fidvid_bsp(bsp_apicid, sysinfo->nodes);
209 init_fidvid_stage2(bsp_apicid, 0); // BSP is node 0
214 /* show final fid and vid */
215 msr=rdmsr(0xc0010071);
216 printk(BIOS_DEBUG, "End FIDVIDMSR 0xc0010071 0x%08x 0x%08x\n", msr.hi, msr.lo);
221 /* Reset for HT, FIDVID, PLL and errata changes to take affect. */
222 if (!warm_reset_detect(0)) {
223 print_info("...WARM RESET...\n\n\n");
225 die("After soft_reset_x - shouldn't see this message!!!\n");
228 /* It's the time to set ctrl in sysinfo now; */
229 fill_mem_ctrl(sysinfo->nodes, sysinfo->ctrl, spd_addr);
232 //do we need apci timer, tsc...., only debug need it for better output
233 /* all ap stopped? */
234 // init_timer(); // Need to use TMICT to synconize FID/VID
236 printk(BIOS_DEBUG, "raminit_amdmct()\n");
237 raminit_amdmct(sysinfo);
240 bcm5785_early_setup();