2 #include <device/pci_def.h>
4 #include <device/pnp_def.h>
5 #include <arch/romcc_io.h>
6 #include <cpu/x86/lapic.h>
8 #include "option_table.h"
9 #include "pc80/mc146818rtc_early.c"
10 #include "pc80/serial.c"
11 #include "console/console.c"
12 #include "lib/ramtest.c"
13 #include "southbridge/intel/i82801ex/i82801ex_early_smbus.c"
14 #include "northbridge/intel/e7520/raminit.h"
15 #include "superio/nsc/pc8374/pc8374_early_init.c"
16 #include "cpu/x86/lapic/boot_cpu.c"
17 #include "cpu/x86/mtrr/earlymtrr.c"
20 // Remove comment if resets in this file are actually used.
22 #include "s1850_fixups.c"
23 #include "northbridge/intel/e7520/memory_initialized.c"
24 #include "cpu/x86/bist.h"
26 #define SIO_GPIO_BASE 0x680
27 #define SIO_XBUS_BASE 0x4880
29 #define CONSOLE_SERIAL_DEV PNP_DEV(0x2e, PC8374_SP1)
31 #define DEVPRES_CONFIG ( \
39 #define DEVPRES1_CONFIG (DEVPRES1_D0F1 | DEVPRES1_D8F0)
41 #define RECVENA_CONFIG 0x0808090a
42 #define RECVENB_CONFIG 0x0808090a
44 static inline void activate_spd_rom(const struct mem_controller *ctrl)
48 static inline int spd_read_byte(unsigned device, unsigned address)
50 return smbus_read_byte(device, address);
53 /* this is very highly mainboard dependent, related to wiring */
54 /* from factory BIOS via lspci */
55 #define DIMM_MAP_LOGICAL 0x2841
56 #include "northbridge/intel/e7520/raminit.c"
57 #include "lib/generic_sdram.c"
59 /* IPMI garbage. This is all test stuff, if it really works we'll move it somewhere
62 #define nftransport 0xc
67 #define ipmidata 0xca0
70 static inline void ibfzero(void)
72 while(inb(ipmicsr) & (1<<IBF))
75 static inline void clearobf(void)
80 static inline void waitobf(void)
82 while((inb(ipmicsr) & (1<<OBF)) == 0)
85 /* quite possibly the stupidest interface ever designed. */
86 static inline void first_cmd_byte(unsigned char byte)
96 static inline void next_cmd_byte(unsigned char byte)
101 outb(byte, ipmidata);
104 static inline void last_cmd_byte(unsigned char byte)
110 outb(byte, ipmidata);
113 static inline void read_response_byte(void)
116 if ((inb(ipmicsr)>>6) != 1)
122 outb(0x68, ipmidata);
124 /* see if it is done */
125 if ((inb(ipmicsr)>>6) != 1){
126 /* wait for the dummy read. Which describes this protocol */
132 static inline void ipmidelay(void)
135 for(i = 0; i < 1000; i++) {
140 static inline void bmc_foad(void)
143 /* be safe; make sure it is really ready */
144 while ((inb(ipmicsr)>>6)) {
148 first_cmd_byte(nftransport << 2);
158 /* end IPMI garbage */
160 #include "arch/i386/lib/stages.c"
162 static void main(unsigned long bist)
172 static const struct mem_controller mch[] = {
176 .f0 = PCI_DEV(0, 0x00, 0),
177 .f1 = PCI_DEV(0, 0x00, 1),
178 .f2 = PCI_DEV(0, 0x00, 2),
179 .f3 = PCI_DEV(0, 0x00, 3),
181 /* the wiring on this part is really messed up */
182 /* this is my best guess so far */
183 .channel0 = {(0xa<<3)|0, (0xa<<3)|1, (0xa<<3)|2, (0xa<<3)|3, },
184 .channel1 = {(0xa<<3)|4, (0xa<<3)|5, (0xa<<3)|6, (0xa<<3)|7, },
189 /* observed from serialice */
190 static const u8 earlyinit[] = {
199 /* using SerialICE, we've seen this basic reset sequence on the dell.
200 * we don't understand it as it uses undocumented registers, but
201 * we're going to clone it.
203 /* enable a hidden device. */
204 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
206 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
208 /* read-write lock in CMOS on LPC bridge on ICH5 */
209 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd8, 4);
211 /* operate on undocumented device */
212 l = pci_read_config32(PCI_DEV(0, 0, 2), 0xa4);
214 pci_write_config32(PCI_DEV(0, 0, 2), 0xa4, l);
216 l = pci_read_config32(PCI_DEV(0, 0, 2), 0x9c);
218 pci_write_config32(PCI_DEV(0, 0, 2), 0x9c, l);
220 /* disable undocumented device */
221 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
223 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
225 /* set up LPC bridge bits, some of which reply on undocumented
229 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xd8);
231 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd8, b);
233 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xd4);
235 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd4, b);
237 /* ACPI base address */
238 pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x40, 0x800);
240 /* Enable specific ACPI features */
241 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0x44);
243 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x44, b);
247 outw(w|0x800, 0x868);
253 dell does this so leave it here so I don't forget
256 pci_write_config16(PCI_DEV(0, 0x1f, 3), 0x20, 0x08c0);
263 /* another device enable? */
264 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
266 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
269 l = pci_read_config32(PCI_DEV(0, 8, 0), 0xc0);
270 do_reset = l & 0x8000000;
272 pci_write_config32(PCI_DEV(0, 8, 0), 0xc0, l);
279 /* Skip this if there was a built in self test failure */
281 if (memory_initialized()) {
285 /* Setup the console */
286 mainboard_set_ich5();
288 pc8374_enable_dev(CONSOLE_SERIAL_DEV, CONFIG_TTYS0_BASE);
292 /* stuff we seem to need */
293 pc8374_enable_dev(PNP_DEV(0x2e, PC8374_KBCK), 0);
296 pc8374_enable_dev(PNP_DEV(0x2e, PC8374_GPIO), 0xc20);
298 /* keep this in mind.
299 SerialICE-hlp: outb 002e <= 23
300 SerialICE-hlp: inb 002f => 05
301 SerialICE-hlp: outb 002f <= 05
302 SerialICE-hlp: outb 002e <= 24
303 SerialICE-hlp: inb 002f => c1
304 SerialICE-hlp: outb 002f <= c1
307 /* Halt if there was a built in self test failure */
308 // report_bist_failure(bist);
310 /* MOVE ME TO A BETTER LOCATION !!! */
311 /* config LPC decode for flash memory access */
313 dev = pci_locate_device(PCI_ID(0x8086, 0x24d0), 0);
314 if (dev == PCI_DEV_INVALID) {
315 die("Missing ich5?");
317 pci_write_config32(dev, 0xe8, 0x00000000);
318 pci_write_config8(dev, 0xf0, 0x00);
321 display_cpuid_update_microcode();
330 // dump_spd_registers(&cpu[0]);
332 for(i = 0; i < 1; i++) {
333 dump_spd_registers();
340 // dump_ipmi_registers();
341 mainboard_set_e7520_leds();
344 sdram_initialize(ARRAY_SIZE(mch), mch);
349 dump_pci_device(PCI_DEV(0, 0x00, 0));
350 // dump_bar14(PCI_DEV(0, 0x00, 0));
353 #if 1 // temporarily disabled
354 /* Check the first 1M */
355 // ram_check(0x00000000, 0x000100000);
356 // ram_check(0x00000000, 0x000a0000);
357 // ram_check(0x00100000, 0x01000000);
358 ram_check(0x00100000, 0x00100100);
359 /* check the first 1M in the 3rd Gig */
360 // ram_check(0x30100000, 0x31000000);
363 ram_check(0x00000000, 0x02000000);