2 * This file is part of the coreboot project.
4 * Copyright (C) 2010 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #define SYSTEM_TYPE 1 /* DESKTOP */
18 /* used by incoherent_ht */
19 #define FAM10_SCAN_PCI_BUS 0
20 #define FAM10_ALLOCATE_IO_RANGE 0
24 #include <device/pci_def.h>
25 #include <device/pci_ids.h>
27 #include <device/pnp_def.h>
28 #include <cpu/x86/lapic.h>
29 #include <console/console.h>
30 #include <timestamp.h>
31 #include <cpu/amd/model_10xxx_rev.h>
33 #include <cpu/x86/lapic.h>
34 #include <commonlib/loglevel.h>
35 #include <cpu/x86/bist.h>
36 #include <superio/ite/common/ite.h>
37 #include <superio/ite/it8718f/it8718f.h>
38 #include <cpu/amd/mtrr.h>
39 #include <cpu/amd/car.h>
40 #include <southbridge/amd/sb700/sb700.h>
41 #include <southbridge/amd/sb700/smbus.h>
42 #include <northbridge/amd/amdfam10/raminit.h>
43 #include <northbridge/amd/amdht/ht_wrapper.h>
44 #include <cpu/amd/family_10h-family_15h/init_cpus.h>
45 #include <arch/early_variables.h>
48 #include "southbridge/amd/rs780/early_setup.c"
50 #include "resourcemap.c"
51 #include "cpu/amd/quadcore/quadcore.c"
53 #define SERIAL_DEV PNP_DEV(0x2e, IT8718F_SP1)
55 void activate_spd_rom(const struct mem_controller
*ctrl
);
56 int spd_read_byte(unsigned device
, unsigned address
);
57 extern struct sys_info sysinfo_car
;
59 void activate_spd_rom(const struct mem_controller
*ctrl
) { }
61 int spd_read_byte(u32 device
, u32 address
)
63 return do_smbus_read_byte(SMBUS_IO_BASE
, device
, address
);
67 void cache_as_ram_main(unsigned long bist
, unsigned long cpu_init_detectedx
)
69 struct sys_info
*sysinfo
= &sysinfo_car
;
70 static const u8 spd_addr
[] = {RC00
, DIMM0
, DIMM2
, 0, 0, DIMM1
, DIMM3
, 0, 0, };
71 u32 bsp_apicid
= 0, val
;
74 timestamp_init(timestamp_get());
75 timestamp_add_now(TS_START_ROMSTAGE
);
77 if (!cpu_init_detectedx
&& boot_cpu()) {
78 /* Nothing special needs to be done to find bus 0 */
79 /* Allow the HT devices to be found */
80 /* mov bsp to bus 0xff when > 8 nodes */
81 set_bsp_node_CHtExtNodeCfgEn();
83 sb7xx_51xx_pci_port80();
89 bsp_apicid
= init_cpus(cpu_init_detectedx
, sysinfo
); /* mmconf is inited in init_cpus */
90 /* All cores run this but the BSP(node0,core0) is the only core that returns. */
96 sb7xx_51xx_lpc_init();
98 ite_enable_serial(SERIAL_DEV
, CONFIG_TTYS0_BASE
);
102 /* Halt if there was a built in self test failure */
103 report_bist_failure(bist
);
107 printk(BIOS_DEBUG
, "BSP Family_Model: %08x\n", val
);
108 printk(BIOS_DEBUG
, "*sysinfo range: [%p,%p]\n",sysinfo
,sysinfo
+1);
109 printk(BIOS_DEBUG
, "bsp_apicid = %02x\n", bsp_apicid
);
110 printk(BIOS_DEBUG
, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx
);
112 /* Setup sysinfo defaults */
113 set_sysinfo_in_ram(0);
115 update_microcode(val
);
122 amd_ht_init(sysinfo
);
125 /* Setup nodes PCI space and start core 0 AP init. */
126 finalize_node_setup(sysinfo
);
128 /* Setup any mainboard PCI settings etc. */
129 setup_mb_resource_map();
132 /* wait for all the APs core0 started by finalize_node_setup. */
133 /* FIXME: A bunch of cores are going to start output to serial at once.
134 It would be nice to fixup prink spinlocks for ROM XIP mode.
135 I think it could be done by putting the spinlock flag in the cache
136 of the BSP located right after sysinfo.
138 wait_all_core0_started();
140 #if IS_ENABLED(CONFIG_LOGICAL_CPUS)
141 /* Core0 on each node is configured. Now setup any additional cores. */
142 printk(BIOS_DEBUG
, "start_other_cores()\n");
143 start_other_cores(bsp_apicid
);
145 wait_all_other_cores_started(bsp_apicid
);
150 /* run _early_setup before soft-reset. */
152 sb7xx_51xx_early_setup();
154 #if IS_ENABLED(CONFIG_SET_FIDVID)
155 msr
= rdmsr(0xc0010071);
156 printk(BIOS_DEBUG
, "\nBegin FIDVID MSR 0xc0010071 0x%08x 0x%08x\n", msr
.hi
, msr
.lo
);
158 /* FIXME: The sb fid change may survive the warm reset and only
159 need to be done once.*/
160 enable_fid_change_on_sb(sysinfo
->sbbusn
, sysinfo
->sbdn
);
164 if (!warm_reset_detect(0)) { /* BSP is node 0 */
165 init_fidvid_bsp(bsp_apicid
, sysinfo
->nodes
);
167 init_fidvid_stage2(bsp_apicid
, 0); /* BSP is node 0 */
172 /* show final fid and vid */
173 msr
= rdmsr(0xc0010071);
174 printk(BIOS_DEBUG
, "End FIDVIDMSR 0xc0010071 0x%08x 0x%08x\n", msr
.hi
, msr
.lo
);
179 /* Reset for HT, FIDVID, PLL and errata changes to take affect. */
180 if (!warm_reset_detect(0)) {
181 printk(BIOS_INFO
, "...WARM RESET...\n\n\n");
183 die("After soft_reset_x - shouldn't see this message!!!\n");
188 /* It's the time to set ctrl in sysinfo now; */
189 printk(BIOS_DEBUG
, "fill_mem_ctrl()\n");
190 fill_mem_ctrl(sysinfo
->nodes
, sysinfo
->ctrl
, spd_addr
);
194 timestamp_add_now(TS_BEFORE_INITRAM
);
195 printk(BIOS_DEBUG
, "raminit_amdmct()\n");
196 raminit_amdmct(sysinfo
);
197 timestamp_add_now(TS_AFTER_INITRAM
);
199 cbmem_initialize_empty();
202 amdmct_cbmem_store_info(sysinfo
);
204 rs780_before_pci_init();
205 sb7xx_51xx_before_pci_init();
211 * BOOL AMD_CB_ManualBUIDSwapList(u8 Node, u8 Link, u8 **List)
213 * This routine is called every time a non-coherent chain is processed.
214 * BUID assignment may be controlled explicitly on a non-coherent chain. Provide a
215 * swap list. The first part of the list controls the BUID assignment and the
216 * second part of the list provides the device to device linking. Device orientation
217 * can be detected automatically, or explicitly. See documentation for more details.
219 * Automatic non-coherent init assigns BUIDs starting at 1 and incrementing sequentially
220 * based on each device's unit count.
223 * @param[in] node = The node on which this chain is located
224 * @param[in] link = The link on the host for this chain
225 * @param[out] List = supply a pointer to a list
227 BOOL
AMD_CB_ManualBUIDSwapList (u8 node
, u8 link
, const u8
**List
)
229 static const u8 swaplist
[] = { 0xFF, CONFIG_HT_CHAIN_UNITID_BASE
, CONFIG_HT_CHAIN_END_UNITID_BASE
, 0xFF };
230 /* If the BUID was adjusted in early_ht we need to do the manual override */
231 if ((CONFIG_HT_CHAIN_UNITID_BASE
!= 0) && (CONFIG_HT_CHAIN_END_UNITID_BASE
!= 0)) {
232 printk(BIOS_DEBUG
, "AMD_CB_ManualBUIDSwapList()\n");
233 if ((node
== 0) && (link
== 0)) { /* BSP SB link */