4 #include <device/pci_def.h>
6 #include <device/pnp_def.h>
7 #include <arch/romcc_io.h>
8 #include <cpu/x86/lapic.h>
10 #include "option_table.h"
11 #include "pc80/mc146818rtc_early.c"
12 #include "pc80/serial.c"
13 #include "arch/i386/lib/console.c"
14 #include "lib/ramtest.c"
15 #include "southbridge/intel/i82801ex/i82801ex_early_smbus.c"
16 #include "northbridge/intel/e7520/raminit.h"
17 #include "superio/nsc/pc8374/pc8374_early_init.c"
18 #include "cpu/x86/lapic/boot_cpu.c"
19 #include "cpu/x86/mtrr/earlymtrr.c"
22 // Remove comment if resets in this file are actually used.
24 #include "s1850_fixups.c"
25 #include "northbridge/intel/e7520/memory_initialized.c"
26 #include "cpu/x86/bist.h"
29 #define SIO_GPIO_BASE 0x680
30 #define SIO_XBUS_BASE 0x4880
32 #define CONSOLE_SERIAL_DEV PNP_DEV(0x2e, PC8374_SP1)
34 #define DEVPRES_CONFIG ( \
42 #define DEVPRES1_CONFIG (DEVPRES1_D0F1 | DEVPRES1_D8F0)
44 #define RECVENA_CONFIG 0x0808090a
45 #define RECVENB_CONFIG 0x0808090a
47 static inline void activate_spd_rom(const struct mem_controller *ctrl)
51 static inline int spd_read_byte(unsigned device, unsigned address)
53 return smbus_read_byte(device, address);
56 /* this is very highly mainboard dependent, related to wiring */
57 /* from factory BIOS via lspci */
58 #define DIMM_MAP_LOGICAL 0x2841
59 #include "northbridge/intel/e7520/raminit.c"
60 #include "lib/generic_sdram.c"
63 /* IPMI garbage. This is all test stuff, if it really works we'll move it somewhere
66 #define nftransport 0xc
71 #define ipmidata 0xca0
75 static inline void ibfzero(void)
77 while(inb(ipmicsr) & (1<<IBF))
80 static inline void clearobf(void)
85 static inline void waitobf(void)
87 while((inb(ipmicsr) & (1<<OBF)) == 0)
90 /* quite possibly the stupidest interface ever designed. */
91 static inline void first_cmd_byte(unsigned char byte)
101 static inline void next_cmd_byte(unsigned char byte)
106 outb(byte, ipmidata);
109 static inline void last_cmd_byte(unsigned char byte)
115 outb(byte, ipmidata);
118 static inline void read_response_byte(void)
121 if ((inb(ipmicsr)>>6) != 1)
127 outb(0x68, ipmidata);
129 /* see if it is done */
130 if ((inb(ipmicsr)>>6) != 1){
131 /* wait for the dummy read. Which describes this protocol */
137 static inline void ipmidelay(void)
140 for(i = 0; i < 1000; i++) {
145 static inline void bmc_foad(void)
148 /* be safe; make sure it is really ready */
149 while ((inb(ipmicsr)>>6)) {
153 first_cmd_byte(nftransport << 2);
163 /* end IPMI garbage */
165 static void main(unsigned long bist)
175 static const struct mem_controller mch[] = {
178 .f0 = PCI_DEV(0, 0x00, 0),
179 .f1 = PCI_DEV(0, 0x00, 1),
180 .f2 = PCI_DEV(0, 0x00, 2),
181 .f3 = PCI_DEV(0, 0x00, 3),
182 /* the wiring on this part is really messed up */
183 /* this is my best guess so far */
184 .channel0 = {(0xa<<3)|0, (0xa<<3)|1, (0xa<<3)|2, (0xa<<3)|3, },
185 .channel1 = {(0xa<<3)|4, (0xa<<3)|5, (0xa<<3)|6, (0xa<<3)|7, },
190 /* observed from serialice */
191 static const u8 earlyinit[] = {
200 /* using SerialICE, we've seen this basic reset sequence on the dell.
201 * we don't understand it as it uses undocumented registers, but
202 * we're going to clone it.
204 /* enable a hidden device. */
205 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
207 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
209 /* read-write lock in CMOS on LPC bridge on ICH5 */
210 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd8, 4);
212 /* operate on undocumented device */
213 l = pci_read_config32(PCI_DEV(0, 0, 2), 0xa4);
215 pci_write_config32(PCI_DEV(0, 0, 2), 0xa4, l);
217 l = pci_read_config32(PCI_DEV(0, 0, 2), 0x9c);
219 pci_write_config32(PCI_DEV(0, 0, 2), 0x9c, l);
221 /* disable undocumented device */
222 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
224 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
226 /* set up LPC bridge bits, some of which reply on undocumented
230 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xd8);
232 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd8, b);
234 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xd4);
236 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd4, b);
238 /* ACPI base address */
239 pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x40, 0x800);
241 /* Enable specific ACPI features */
242 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0x44);
244 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x44, b);
248 outw(w|0x800, 0x868);
254 dell does this so leave it here so I don't forget
257 pci_write_config16(PCI_DEV(0, 0x1f, 3), 0x20, 0x08c0);
264 /* another device enable? */
265 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
267 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
270 l = pci_read_config32(PCI_DEV(0, 8, 0), 0xc0);
271 do_reset = l & 0x8000000;
273 pci_write_config32(PCI_DEV(0, 8, 0), 0xc0, l);
280 /* Skip this if there was a built in self test failure */
282 if (memory_initialized()) {
283 asm volatile ("jmp __cpu_reset");
286 /* Setup the console */
287 mainboard_set_ich5();
289 pc8374_enable_dev(CONSOLE_SERIAL_DEV, CONFIG_TTYS0_BASE);
294 /* stuff we seem to need */
295 pc8374_enable_dev(PNP_DEV(0x2e, PC8374_KBCK), 0);
298 pc8374_enable_dev(PNP_DEV(0x2e, PC8374_GPIO), 0xc20);
300 /* keep this in mind.
301 SerialICE-hlp: outb 002e <= 23
302 SerialICE-hlp: inb 002f => 05
303 SerialICE-hlp: outb 002f <= 05
304 SerialICE-hlp: outb 002e <= 24
305 SerialICE-hlp: inb 002f => c1
306 SerialICE-hlp: outb 002f <= c1
309 /* Halt if there was a built in self test failure */
310 // report_bist_failure(bist);
312 /* MOVE ME TO A BETTER LOCATION !!! */
313 /* config LPC decode for flash memory access */
315 dev = pci_locate_device(PCI_ID(0x8086, 0x24d0), 0);
316 if (dev == PCI_DEV_INVALID) {
317 die("Missing ich5?");
319 pci_write_config32(dev, 0xe8, 0x00000000);
320 pci_write_config8(dev, 0xf0, 0x00);
323 display_cpuid_update_microcode();
332 // dump_spd_registers(&cpu[0]);
334 for(i = 0; i < 1; i++) {
335 dump_spd_registers();
342 // dump_ipmi_registers();
343 mainboard_set_e7520_leds();
346 sdram_initialize(ARRAY_SIZE(mch), mch);
351 dump_pci_device(PCI_DEV(0, 0x00, 0));
352 // dump_bar14(PCI_DEV(0, 0x00, 0));
355 #if 1 // temporarily disabled
356 /* Check the first 1M */
357 // ram_check(0x00000000, 0x000100000);
358 // ram_check(0x00000000, 0x000a0000);
359 // ram_check(0x00100000, 0x01000000);
360 ram_check(0x00100000, 0x00100100);
361 /* check the first 1M in the 3rd Gig */
362 // ram_check(0x30100000, 0x31000000);
365 ram_check(0x00000000, 0x02000000);