2 #define ENABLE_APIC_EXT_ID 1
3 #define APIC_ID_OFFSET 0x10
5 #include <device/pci_def.h>
7 #include <device/pnp_def.h>
8 #include <arch/romcc_io.h>
9 #include <cpu/x86/lapic.h>
11 #include "option_table.h"
12 #include "pc80/mc146818rtc_early.c"
13 #include "pc80/serial.c"
14 #include "arch/i386/lib/console.c"
15 #include "ram/ramtest.c"
16 #include "southbridge/amd/amd8111/amd8111_early_smbus.c"
17 #include "northbridge/amd/amdk8/raminit.h"
18 #include "cpu/amd/model_fxx/apic_timer.c"
19 #include "lib/delay.c"
20 #include "cpu/x86/lapic/boot_cpu.c"
21 #include "northbridge/amd/amdk8/reset_test.c"
22 #include "northbridge/amd/amdk8/debug.c"
23 #include "northbridge/amd/amdk8/incoherent_ht.c"
24 #include "northbridge/amd/amdk8/cpu_rev.c"
25 #include "superio/winbond/w83627hf/w83627hf_early_serial.c"
26 #include "cpu/amd/mtrr/amd_earlymtrr.c"
27 #include "cpu/x86/bist.h"
29 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
31 static void hard_reset(void)
34 pci_write_config8(PCI_DEV(0, 0x04, 3), 0x41, 0xf1);
38 static void soft_reset(void)
41 pci_write_config8(PCI_DEV(0, 0x04, 0), 0x47, 1);
45 * GPIO28 of 8111 will control H0_MEMRESET_L
46 * GPIO29 of 8111 will control H1_MEMRESET_L
48 static void memreset_setup(void)
50 if (is_cpu_pre_c0()) {
51 /* Set the memreset low */
52 outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(0<<0),
53 SMBUS_IO_BASE + 0xc0 + 28);
54 /* Ensure the BIOS has control of the memory lines */
55 outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(0<<0),
56 SMBUS_IO_BASE + 0xc0 + 29);
58 /* Ensure the CPU has controll of the memory lines */
59 outb((0 << 7)|(0 << 6)|(0<<5)|(0<<4)|(1<<2)|(1<<0),
60 SMBUS_IO_BASE + 0xc0 + 29);
64 static void memreset(int controllers, const struct mem_controller *ctrl)
66 if (is_cpu_pre_c0()) {
68 /* Set memreset_high */
69 outb((0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(1<<0),
70 SMBUS_IO_BASE + 0xc0 + 28);
75 static inline void activate_spd_rom(const struct mem_controller *ctrl)
77 #define SMBUS_SWITCH1 0x71
78 #define SMBUS_SWITCH2 0x73
79 /* Switch 1: pca 9545, Switch 2: pca 9543 */
80 unsigned device = (ctrl->channel0[0]) >> 8;
81 /* Disable all outputs on SMBus switch 1 */
82 smbus_send_byte(SMBUS_SWITCH1, 0x0);
83 /* Select SMBus switch 2 Channel 0/1 */
84 smbus_send_byte(SMBUS_SWITCH2, device);
87 static inline int spd_read_byte(unsigned device, unsigned address)
89 return smbus_read_byte(device, address);
92 #include "northbridge/amd/amdk8/raminit.c"
93 #include "northbridge/amd/amdk8/coherent_ht.c"
94 #include "sdram/generic_sdram.c"
95 #include "resourcemap.c"
100 #define NODE_RAM(x) \
102 .f0 = PCI_DEV(0, 0x18+x, 0), \
103 .f1 = PCI_DEV(0, 0x18+x, 1), \
104 .f2 = PCI_DEV(0, 0x18+x, 2), \
105 .f3 = PCI_DEV(0, 0x18+x, 3)
107 static void main(unsigned long bist)
109 static const struct mem_controller cpu[] = {
111 .channel0 = { (0xa0>>1)|CHAN0, (0xa4>>1)|CHAN0, 0, 0 },
112 .channel1 = { (0xa2>>1)|CHAN0, (0xa6>>1)|CHAN0, 0, 0 }
115 .channel0 = { (0xa8>>1)|CHAN0, (0xac>>1)|CHAN0, 0, 0 },
116 .channel1 = { (0xaa>>1)|CHAN0, (0xae>>1)|CHAN0, 0, 0 }
119 .channel0 = { (0xa0>>1)|CHAN1, (0xa4>>1)|CHAN1, 0, 0 },
120 .channel1 = { (0xa2>>1)|CHAN1, (0xa6>>1)|CHAN1, 0, 0 }
123 .channel0 = { (0xa8>>1)|CHAN1, (0xac>>1)|CHAN1, 0, 0 },
124 .channel1 = { (0xaa>>1)|CHAN1, (0xae>>1)|CHAN1, 0, 0 }
132 /* Skip this if there was a built in self test failure */
133 amd_early_mtrr_init();
137 nodeid=lapicid() & 0xf;
140 #if ENABLE_APIC_EXT_ID == 1
141 enable_apic_ext_id(nodeid);
143 /* CPU apicid is from 0x10 */
144 lapic_write(LAPIC_ID, ( lapic_read(LAPIC_ID)
145 | (APIC_ID_OFFSET<<24) ) );
148 if (cpu_init_detected(nodeid)) {
149 asm volatile ("jmp __cpu_reset");
151 distinguish_cpu_resets(nodeid);
156 /* Setup the console */
157 w83627hf_enable_serial(SERIAL_DEV, TTYS0_BASE);
161 /* Halt if there was a built in self test failure */
162 report_bist_failure(bist);
164 setup_aruma_resource_map();
165 needs_reset = setup_coherent_ht_domain();
166 needs_reset=ht_setup_chains_x();
175 #if (ALLOW_HT_OVERCLOCKING==1) && (USE_FALLBACK_IMAGE==0)
176 if(read_option(CMOS_VSTART_amdk8_1GHz, CMOS_VLEN_amdk8_1GHz, 0))
178 print_debug("AMDK8 allowed at 1GHz\r\n");
180 print_debug("AMDK8 allowed at 800Hz only\r\n");
182 if(read_option(CMOS_VSTART_amd8131_800MHz, CMOS_VLEN_amd8131_800MHz, 0))
184 print_debug("AMD8131 allowed at 800MHz\r\n");
186 print_debug("AMD8131 allowed at 600Hz only\r\n");
190 print_info("HyperT reset -\r\n");
197 sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
200 /* Check the first 1M */
201 ram_check(0x00000000, 0x000100000);