3 #include <device/pci_def.h>
4 #include "arch/romcc_io.h"
5 #include "pc80/serial.c"
6 #include "arch/i386/lib/console.c"
7 #include "ram/ramtest.c"
8 #include "northbridge/amd/amdk8/early_ht.c"
9 #include "southbridge/amd/amd8111/amd8111_early_smbus.c"
10 #include "northbridge/amd/amdk8/raminit.c"
11 #include "northbridge/amd/amdk8/coherent_ht.c"
12 #include "sdram/generic_sdram.c"
15 #define HT_INIT_CONTROL 0x6c
17 #define HTIC_ColdR_Detect (1<<4)
18 #define HTIC_BIOSR_Detect (1<<5)
19 #define HTIC_INIT_Detect (1<<6)
21 static int boot_cpu(void)
23 volatile unsigned long *local_apic;
24 unsigned long apic_id;
28 bsp = !!(msr.lo & (1 << 8));
30 print_debug("Bootstrap processor\r\n");
32 print_debug("Application processor\r\n");
38 static int cpu_init_detected(void)
45 htic = pci_read_config32(PCI_DEV(0, 0x18, 0), HT_INIT_CONTROL);
47 print_debug("htic: ");
48 print_debug_hex32(htic);
51 if (!(htic & HTIC_ColdR_Detect)) {
52 print_debug("Cold Reset.\r\n");
54 if ((htic & HTIC_ColdR_Detect) && !(htic & HTIC_BIOSR_Detect)) {
55 print_debug("BIOS generated Reset.\r\n");
57 if (htic & HTIC_INIT_Detect) {
58 print_debug("Init event.\r\n");
61 cpu_init = (htic & HTIC_INIT_Detect);
63 print_debug("CPU INIT Detected.\r\n");
69 static void print_debug_pci_dev(unsigned dev)
72 print_debug_hex8((dev >> 16) & 0xff);
73 print_debug_char(':');
74 print_debug_hex8((dev >> 11) & 0x1f);
75 print_debug_char('.');
76 print_debug_hex8((dev >> 8) & 7);
79 static void print_pci_devices(void)
82 for(dev = PCI_DEV(0, 0, 0);
83 dev <= PCI_DEV(0, 0x1f, 0x7);
84 dev += PCI_DEV(0,0,1)) {
86 id = pci_read_config32(dev, PCI_VENDOR_ID);
87 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
88 (((id >> 16) & 0xffff) == 0xffff) ||
89 (((id >> 16) & 0xffff) == 0x0000)) {
92 print_debug_pci_dev(dev);
98 static void dump_pci_device(unsigned dev)
101 print_debug_pci_dev(dev);
104 for(i = 0; i <= 255; i++) {
106 if ((i & 0x0f) == 0) {
108 print_debug_char(':');
110 val = pci_read_config8(dev, i);
111 print_debug_char(' ');
112 print_debug_hex8(val);
113 if ((i & 0x0f) == 0x0f) {
119 static void dump_spd_registers(const struct mem_controller *ctrl)
123 for(i = 0; i < 4; i++) {
125 device = ctrl->channel0[i];
128 print_debug("dimm: ");
131 print_debug_hex8(device);
132 for(j = 0; j < 256; j++) {
135 if ((j & 0xf) == 0) {
140 status = smbus_read_byte(device, j);
142 print_debug("bad device\r\n");
145 byte = status & 0xff;
146 print_debug_hex8(byte);
147 print_debug_char(' ');
151 device = ctrl->channel1[i];
154 print_debug("dimm: ");
157 print_debug_hex8(device);
158 for(j = 0; j < 256; j++) {
161 if ((j & 0xf) == 0) {
166 status = smbus_read_byte(device, j);
168 print_debug("bad device\r\n");
171 byte = status & 0xff;
172 print_debug_hex8(byte);
173 print_debug_char(' ');
181 static void main(void)
183 static const struct mem_controller cpu0 = {
184 .f0 = PCI_DEV(0, 0x18, 0),
185 .f1 = PCI_DEV(0, 0x18, 1),
186 .f2 = PCI_DEV(0, 0x18, 2),
187 .f3 = PCI_DEV(0, 0x18, 3),
188 .channel0 = { (0xa << 3), (0xa << 3)|1, 0, 0 },
189 .channel1 = { 0, 0, 0, 0},
194 print_debug(" XIP_ROM_BASE: ");
195 print_debug_hex32(XIP_ROM_BASE);
196 print_debug(" XIP_ROM_SIZE: ");
197 print_debug_hex32(XIP_ROM_SIZE);
200 if (boot_cpu() && !cpu_init_detected()) {
201 setup_default_resource_map();
202 setup_coherent_ht_domain();
203 enumerate_ht_chain();
206 dump_spd_registers(&cpu0);
207 sdram_initialize(&cpu0);
209 dump_pci_device(PCI_DEV(0, 0x18, 2));
211 /* Check the first 512M */
213 msr = rdmsr(TOP_MEM);
214 print_debug("TOP_MEM: ");
215 print_debug_hex32(msr.hi);
216 print_debug_hex32(msr.lo);
218 ram_check(0x00000000, msr.lo);