2 //#define MAXIMUM_CONSOLE_LOGLEVEL 9
3 //#define DEFAULT_CONSOLE_LOGLEVEL 9
6 #include <device/pci_def.h>
8 #include <device/pnp_def.h>
9 #include <arch/romcc_io.h>
10 #include <cpu/x86/lapic.h>
12 #include "option_table.h"
13 #include "pc80/mc146818rtc_early.c"
14 #include "pc80/serial.c"
15 #include "arch/i386/lib/console.c"
16 #include "ram/ramtest.c"
17 #include "northbridge/amd/amdk8/incoherent_ht.c"
18 #include "southbridge/amd/amd8111/amd8111_early_smbus.c"
19 #include "northbridge/amd/amdk8/raminit.h"
20 #include "cpu/amd/model_fxx/apic_timer.c"
21 #include "lib/delay.c"
22 #include "cpu/x86/lapic/boot_cpu.c"
23 #include "northbridge/amd/amdk8/reset_test.c"
24 #include "northbridge/amd/amdk8/debug.c"
25 #include "northbridge/amd/amdk8/cpu_rev.c"
26 #include "superio/NSC/pc87360/pc87360_early_serial.c"
27 #include "cpu/amd/mtrr/amd_earlymtrr.c"
28 #include "cpu/x86/bist.h"
30 #define SERIAL_DEV PNP_DEV(0x2e, PC87360_SP1)
32 static void hard_reset(void)
36 pci_write_config8(PCI_DEV(0, 0x04, 3), 0x41, 0xf1);
41 static void soft_reset(void)
44 pci_write_config8(PCI_DEV(0, 0x04, 0), 0x47, 1);
48 * GPIO28 of 8111 will control H0_MEMRESET_L
49 * GPIO29 of 8111 will control H1_MEMRESET_L
51 static void memreset_setup(void)
53 if (is_cpu_pre_c0()) {
54 /* Set the memreset low */
55 outb((0 << 7) | (0 << 6) | (0 << 5) | (0 << 4) | (1 << 2) |
56 (0 << 0), SMBUS_IO_BASE + 0xc0 + 28);
57 /* Ensure the BIOS has control of the memory lines */
58 outb((0 << 7) | (0 << 6) | (0 << 5) | (0 << 4) | (1 << 2) |
59 (0 << 0), SMBUS_IO_BASE + 0xc0 + 29);
61 /* Ensure the CPU has controll of the memory lines */
62 outb((0 << 7) | (0 << 6) | (0 << 5) | (0 << 4) | (1 << 2) |
63 (1 << 0), SMBUS_IO_BASE + 0xc0 + 29);
67 static void memreset(int controllers, const struct mem_controller *ctrl)
69 if (is_cpu_pre_c0()) {
71 /* Set memreset_high */
72 outb((0 << 7) | (0 << 6) | (0 << 5) | (0 << 4) | (1 << 2) |
73 (1 << 0), SMBUS_IO_BASE + 0xc0 + 28);
79 * generate_row is specific to board implementation
83 static unsigned int generate_row(uint8_t node, uint8_t row,
86 /* Routing Table Node i
88 * F0: 0x40, 0x44, 0x48, 0x4c, 0x50, 0x54, 0x58, 0x5c
89 * i: 0, 1, 2, 3, 4, 5, 6, 7
91 * [ 0: 3] Request Route
92 * [0] Route to this node
96 * [11: 8] Response Route
97 * [0] Route to this node
100 * [3] Route to Link 2
101 * [19:16] Broadcast route
102 * [0] Route to this node
103 * [1] Route to Link 0
104 * [2] Route to Link 1
105 * [3] Route to Link 2
108 uint32_t ret = 0x00010101; /* default row entry */
110 static const unsigned int rows_2p[2][2] = {
111 {0x00030101, 0x00010202},
112 {0x00010202, 0x00030101}
116 static const unsigned int rows_4p[4][4] = {
117 {0x00070101, 0x00010202, 0x00030404, 0x00010204},
118 {0x00010202, 0x000b0101, 0x00010208, 0x00030808},
119 {0x00030808, 0x00010208, 0x000b0101, 0x00010202},
120 {0x00010204, 0x00030404, 0x00010202, 0x00070101}
123 if (!(node >= maxnodes || row >= maxnodes)) {
126 ret = rows_2p[node][row];
129 ret = rows_4p[node][row];
136 #if ( FAKE_SPDROM != 1 )
137 static inline void activate_spd_rom(const struct mem_controller *ctrl)
139 #define SMBUS_HUB 0x18
140 unsigned device = (ctrl->channel0[0]) >> 8;
141 smbus_write_byte(SMBUS_HUB, 0x01, device);
142 smbus_write_byte(SMBUS_HUB, 0x03, 0);
145 static inline int spd_read_byte(unsigned device, unsigned address)
147 return smbus_read_byte(device & 0xff, address);
153 // #include "northbridge/amd/amdk8/setup_resource_map.c"
154 #include "northbridge/amd/amdk8/raminit.c"
155 #include "northbridge/amd/amdk8/coherent_ht.c"
156 #include "sdram/generic_sdram.c"
157 /* quartet does not want the default */
158 #include "resourcemap.c"
160 #define RC0 ((1<<1)<<8)
161 #define RC1 ((1<<2)<<8)
162 #define RC2 ((1<<3)<<8)
163 #define RC3 ((1<<4)<<8)
170 static void main(unsigned long bist)
172 static const struct mem_controller cpu[] = {
175 .f0 = PCI_DEV(0, 0x18, 0),
176 .f1 = PCI_DEV(0, 0x18, 1),
177 .f2 = PCI_DEV(0, 0x18, 2),
178 .f3 = PCI_DEV(0, 0x18, 3),
179 .channel0 = {RC0 | DIMM0, RC0 | DIMM2, 0, 0},
180 .channel1 = {RC0 | DIMM1, RC0 | DIMM3, 0, 0},
184 .f0 = PCI_DEV(0, 0x19, 0),
185 .f1 = PCI_DEV(0, 0x19, 1),
186 .f2 = PCI_DEV(0, 0x19, 2),
187 .f3 = PCI_DEV(0, 0x19, 3),
188 .channel0 = {RC1 | DIMM0, RC1 | DIMM2, 0, 0},
189 .channel1 = {RC1 | DIMM1, RC1 | DIMM3, 0, 0},
193 .f0 = PCI_DEV(0, 0x1a, 0),
194 .f1 = PCI_DEV(0, 0x1a, 1),
195 .f2 = PCI_DEV(0, 0x1a, 2),
196 .f3 = PCI_DEV(0, 0x1a, 3),
197 .channel0 = {RC2 | DIMM0, RC2 | DIMM2, 0, 0},
198 .channel1 = {RC2 | DIMM1, RC2 | DIMM3, 0, 0},
202 .f0 = PCI_DEV(0, 0x1b, 0),
203 .f1 = PCI_DEV(0, 0x1b, 1),
204 .f2 = PCI_DEV(0, 0x1b, 2),
205 .f3 = PCI_DEV(0, 0x1b, 3),
206 .channel0 = {RC3 | DIMM0, RC3 | DIMM2, 0, 0},
207 .channel1 = {RC3 | DIMM1, RC3 | DIMM3, 0, 0},
211 static const struct ht_chain ht_c[] = {
212 { /* Link 2 of CPU0 */
213 .devreg = 0xe0, /* Preset bus num in resource map */
215 { /* Link 1 of CPU1 */
216 .devreg = 0xe4, /* Preset bus num in resource map */
223 /* Skip this if there was a built in self test failure */
224 amd_early_mtrr_init();
227 /* Has this cpu already booted? */
228 if (cpu_init_detected()) {
229 asm volatile ("jmp __cpu_reset");
232 distinguish_cpu_resets();
238 /* Setup the console */
239 pc87360_enable_serial(SERIAL_DEV, TTYS0_BASE);
243 /* Halt if there was a built in self test failure */
244 report_bist_failure(bist);
246 setup_quartet_resource_map();
247 needs_reset = setup_coherent_ht_domain();
248 // needs_reset |= ht_setup_chain(PCI_DEV(0, 0x18, 0), 0x80);
249 needs_reset |= ht_setup_chains(ht_c, sizeof(ht_c)/sizeof(ht_c[0]));
251 print_info("ht reset -\r\n");
259 dump_spd_registers(&cpu[0]);
262 sdram_initialize(sizeof(cpu) / sizeof(cpu[0]), cpu);
268 dump_pci_device(PCI_DEV(0, 0x18, 2));
271 /* Check the first 1M */
272 ram_check(0x00000000, 0x000100000);