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 <console/console.h>
9 #include "lib/ramtest.c"
10 #include "southbridge/intel/i82801ex/i82801ex_early_smbus.c"
11 #include "northbridge/intel/e7520/raminit.h"
12 #include "superio/nsc/pc8374/pc8374_early_init.c"
13 #include "cpu/x86/lapic/boot_cpu.c"
14 #include "cpu/x86/mtrr/earlymtrr.c"
17 // Remove comment if resets in this file are actually used.
19 #include "s1850_fixups.c"
20 #include "northbridge/intel/e7520/memory_initialized.c"
21 #include "cpu/x86/bist.h"
24 #define CONSOLE_SERIAL_DEV PNP_DEV(0x2e, PC8374_SP1)
26 #define DEVPRES_CONFIG ( \
34 #define DEVPRES1_CONFIG (DEVPRES1_D0F1 | DEVPRES1_D8F0)
36 static inline int spd_read_byte(unsigned device, unsigned address)
38 return smbus_read_byte(device, address);
41 #include "northbridge/intel/e7520/raminit.c"
42 #include "lib/generic_sdram.c"
44 /* IPMI garbage. This is all test stuff, if it really works we'll move it somewhere
47 #define nftransport 0xc
52 #define ipmidata 0xca0
55 static inline void ibfzero(void)
57 while(inb(ipmicsr) & (1<<IBF))
60 static inline void clearobf(void)
65 static inline void waitobf(void)
67 while((inb(ipmicsr) & (1<<OBF)) == 0)
71 /* quite possibly the stupidest interface ever designed. */
72 static inline void first_cmd_byte(unsigned char byte)
82 static inline void next_cmd_byte(unsigned char byte)
90 static inline void last_cmd_byte(unsigned char byte)
99 static inline void read_response_byte(void)
102 if ((inb(ipmicsr)>>6) != 1)
108 outb(0x68, ipmidata);
110 /* see if it is done */
111 if ((inb(ipmicsr)>>6) != 1){
112 /* wait for the dummy read. Which describes this protocol */
118 static inline void ipmidelay(void)
121 for(i = 0; i < 1000; i++) {
126 static inline void bmc_foad(void)
129 /* be safe; make sure it is really ready */
130 while ((inb(ipmicsr)>>6)) {
134 first_cmd_byte(nftransport << 2);
144 /* end IPMI garbage */
146 #include "arch/i386/lib/stages.c"
148 static void main(unsigned long bist)
155 static const struct mem_controller mch[] = {
158 /* the wiring on this part is really messed up */
159 /* this is my best guess so far */
160 .channel0 = {DIMM0, DIMM1, DIMM2, DIMM3, },
161 .channel1 = {DIMM4, DIMM5, DIMM6, DIMM7, },
166 /* observed from serialice */
167 static const u8 earlyinit[] = {
176 /* using SerialICE, we've seen this basic reset sequence on the dell.
177 * we don't understand it as it uses undocumented registers, but
178 * we're going to clone it.
180 /* enable a hidden device. */
181 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
183 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
185 /* read-write lock in CMOS on LPC bridge on ICH5 */
186 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd8, 4);
188 /* operate on undocumented device */
189 l = pci_read_config32(PCI_DEV(0, 0, 2), 0xa4);
191 pci_write_config32(PCI_DEV(0, 0, 2), 0xa4, l);
193 l = pci_read_config32(PCI_DEV(0, 0, 2), 0x9c);
195 pci_write_config32(PCI_DEV(0, 0, 2), 0x9c, l);
197 /* disable undocumented device */
198 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
200 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
202 /* set up LPC bridge bits, some of which reply on undocumented
206 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xd8);
208 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd8, b);
210 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xd4);
212 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd4, b);
214 /* ACPI base address */
215 pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x40, 0x800);
217 /* Enable specific ACPI features */
218 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0x44);
220 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x44, b);
224 outw(w|0x800, 0x868);
230 dell does this so leave it here so I don't forget
233 pci_write_config16(PCI_DEV(0, 0x1f, 3), 0x20, 0x08c0);
240 /* another device enable? */
241 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
243 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
246 l = pci_read_config32(PCI_DEV(0, 8, 0), 0xc0);
247 do_reset = l & 0x8000000;
249 pci_write_config32(PCI_DEV(0, 8, 0), 0xc0, l);
256 /* Skip this if there was a built in self test failure */
258 if (memory_initialized())
261 /* Setup the console */
262 mainboard_set_ich5();
264 pc8374_enable_dev(CONSOLE_SERIAL_DEV, CONFIG_TTYS0_BASE);
268 /* stuff we seem to need */
269 pc8374_enable_dev(PNP_DEV(0x2e, PC8374_KBCK), 0);
272 pc8374_enable_dev(PNP_DEV(0x2e, PC8374_GPIO), 0xc20);
274 /* keep this in mind.
275 SerialICE-hlp: outb 002e <= 23
276 SerialICE-hlp: inb 002f => 05
277 SerialICE-hlp: outb 002f <= 05
278 SerialICE-hlp: outb 002e <= 24
279 SerialICE-hlp: inb 002f => c1
280 SerialICE-hlp: outb 002f <= c1
283 /* Halt if there was a built in self test failure */
284 // report_bist_failure(bist);
286 /* MOVE ME TO A BETTER LOCATION !!! */
287 /* config LPC decode for flash memory access */
289 dev = pci_locate_device(PCI_ID(0x8086, 0x24d0), 0);
290 if (dev == PCI_DEV_INVALID) {
291 die("Missing ich5?");
293 pci_write_config32(dev, 0xe8, 0x00000000);
294 pci_write_config8(dev, 0xf0, 0x00);
297 display_cpuid_update_microcode();
306 // dump_spd_registers(&cpu[0]);
308 for(i = 0; i < 1; i++)
309 dump_spd_registers();
315 // dump_ipmi_registers();
316 mainboard_set_e7520_leds();
318 sdram_initialize(ARRAY_SIZE(mch), mch);
323 dump_pci_device(PCI_DEV(0, 0x00, 0));
324 // dump_bar14(PCI_DEV(0, 0x00, 0));
327 #if 1 // temporarily disabled
328 /* Check the first 1M */
329 // ram_check(0x00000000, 0x000100000);
330 // ram_check(0x00000000, 0x000a0000);
331 // ram_check(0x00100000, 0x01000000);
332 ram_check(0x00100000, 0x00100100);
333 /* check the first 1M in the 3rd Gig */
334 // ram_check(0x30100000, 0x31000000);
337 ram_check(0x00000000, 0x02000000);