3 #include <device/pci_def.h>
4 #include <device/pci_ids.h>
6 #include <device/pnp_def.h>
7 #include <arch/romcc_io.h>
8 #include <pc80/mc146818rtc.h>
9 #include <console/console.h>
10 #include <cpu/amd/model_fxx_rev.h>
11 #include "northbridge/amd/amdk8/amdk8.h"
12 #include "southbridge/amd/amd8111/early_smbus.c"
13 #include "northbridge/amd/amdk8/raminit.h"
14 #include "cpu/amd/model_fxx/apic_timer.c"
15 #include "northbridge/amd/amdk8/reset_test.c"
16 #include "northbridge/amd/amdk8/debug.c"
17 #include "superio/winbond/w83627hf/early_serial.c"
18 #include "cpu/x86/mtrr/earlymtrr.c"
19 #include "cpu/x86/bist.h"
20 #include "southbridge/amd/amd8111/early_ctrl.c"
22 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
24 static void memreset_setup(void)
26 if (is_cpu_pre_c0()) {
27 /* Set the memreset low. */
28 outb((1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 16);
29 /* Ensure the BIOS has control of the memory lines. */
30 outb((1<<2)|(0<<0), SMBUS_IO_BASE + 0xc0 + 17);
32 /* Ensure the CPU has control of the memory lines. */
33 outb((1<<2)|(1<<0), SMBUS_IO_BASE + 0xc0 + 17);
37 static void memreset(int controllers, const struct mem_controller *ctrl)
39 if (is_cpu_pre_c0()) {
41 /* Set memreset high. */
42 outb((1<<2)|(1<<0), SMBUS_IO_BASE + 0xc0 + 16);
47 #define SMBUS_HUB 0x18
49 static inline void activate_spd_rom(const struct mem_controller *ctrl)
52 unsigned device=(ctrl->channel0[0])>>8;
53 /* the very first write always get COL_STS=1 and ABRT_STS=1, so try another time*/
56 ret = smbus_write_byte(SMBUS_HUB, 0x01, device);
57 } while ((ret!=0) && (i-->0));
58 smbus_write_byte(SMBUS_HUB, 0x03, 0);
61 static inline void change_i2c_mux(unsigned device)
64 print_debug("change_i2c_mux i="); print_debug_hex8(device); print_debug("\n");
67 ret = smbus_write_byte(SMBUS_HUB, 0x01, device);
68 print_debug("change_i2c_mux 1 ret="); print_debug_hex32(ret); print_debug("\n");
69 } while ((ret!=0) && (i-->0));
70 ret = smbus_write_byte(SMBUS_HUB, 0x03, 0);
71 print_debug("change_i2c_mux 2 ret="); print_debug_hex32(ret); print_debug("\n");
74 static inline int spd_read_byte(unsigned device, unsigned address)
76 return smbus_read_byte(device, address);
79 #include "northbridge/amd/amdk8/incoherent_ht.c"
80 #include "northbridge/amd/amdk8/raminit.c"
81 #include "resourcemap.c"
82 #include "northbridge/amd/amdk8/coherent_ht.c"
83 #include "lib/generic_sdram.c"
84 #include "cpu/amd/dualcore/dualcore.c"
86 #include "cpu/amd/car/post_cache_as_ram.c"
87 #include "cpu/amd/model_fxx/init_cpus.c"
89 #define RC0 ((1<<1)<<8)
90 #define RC1 ((1<<2)<<8)
92 void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
94 static const uint16_t spd_addr [] = {
96 RC0|DIMM0, RC0|DIMM2, 0, 0,
97 RC0|DIMM1, RC0|DIMM3, 0, 0,
98 #if CONFIG_MAX_PHYSICAL_CPUS > 1
100 RC1|DIMM0, RC1|DIMM2, 0, 0,
101 RC1|DIMM1, RC1|DIMM3, 0, 0,
104 struct sys_info *sysinfo = (struct sys_info *)(CONFIG_DCACHE_RAM_BASE
105 + CONFIG_DCACHE_RAM_SIZE - CONFIG_DCACHE_RAM_GLOBAL_VAR_SIZE);
108 unsigned bsp_apicid = 0;
111 bsp_apicid = init_cpus(cpu_init_detectedx,sysinfo);
113 w83627hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
116 /* Halt if there was a built in self test failure */
117 report_bist_failure(bist);
119 printk(BIOS_DEBUG, "*sysinfo range: [%p,%p]\n",sysinfo,sysinfo+1);
121 setup_dl145g1_resource_map();
122 //setup_default_resource_map();
124 #if CONFIG_MEM_TRAIN_SEQ == 1
125 set_sysinfo_in_ram(0); // in BSP so could hold all ap until sysinfo is in ram
127 setup_coherent_ht_domain();
128 wait_all_core0_started();
129 #if CONFIG_LOGICAL_CPUS==1
130 // It is said that we should start core1 after all core0 launched
132 wait_all_other_cores_started(bsp_apicid);
135 ht_setup_chains_x(sysinfo);
137 needs_reset |= optimize_link_coherent_ht();
138 needs_reset |= optimize_link_incoherent_ht(sysinfo);
141 print_info("ht reset -\n");
142 soft_reset_x(sysinfo->sbbusn, sysinfo->sbdn);
149 activate_spd_rom(&sysinfo->ctrl[i]);
151 for(i=RC0;i<=RC1;i<<=1) {
155 //dump_spd_registers(&sysinfo->ctrl[0]);
156 //dump_spd_registers(&sysinfo->ctrl[1]);
157 //dump_smbus_registers();
159 allow_all_aps_stop(bsp_apicid);
161 //It's the time to set ctrl now;
162 fill_mem_ctrl(sysinfo->nodes, sysinfo->ctrl, spd_addr);
165 sdram_initialize(sysinfo->nodes, sysinfo->ctrl, sysinfo);
167 //dump_pci_devices();