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 "southbridge/intel/i82801ex/early_smbus.c"
10 #include "northbridge/intel/e7520/raminit.h"
11 #include "superio/nsc/pc8374/early_init.c"
12 #include "cpu/x86/lapic/boot_cpu.c"
13 #include "cpu/x86/mtrr/earlymtrr.c"
16 // Remove comment if resets in this file are actually used.
18 #include "s1850_fixups.c"
19 #include "northbridge/intel/e7520/memory_initialized.c"
20 #include "cpu/x86/bist.h"
23 #define CONSOLE_SERIAL_DEV PNP_DEV(0x2e, PC8374_SP1)
25 #define DEVPRES_CONFIG ( \
33 #define DEVPRES1_CONFIG (DEVPRES1_D0F1 | DEVPRES1_D8F0)
35 static inline int spd_read_byte(unsigned device, unsigned address)
37 return smbus_read_byte(device, address);
40 #include "northbridge/intel/e7520/raminit.c"
41 #include "lib/generic_sdram.c"
43 /* IPMI garbage. This is all test stuff, if it really works we'll move it somewhere
46 #define nftransport 0xc
51 #define ipmidata 0xca0
54 static inline void ibfzero(void)
56 while(inb(ipmicsr) & (1<<IBF))
59 static inline void clearobf(void)
64 static inline void waitobf(void)
66 while((inb(ipmicsr) & (1<<OBF)) == 0)
70 /* quite possibly the stupidest interface ever designed. */
71 static inline void first_cmd_byte(unsigned char byte)
81 static inline void next_cmd_byte(unsigned char byte)
89 static inline void last_cmd_byte(unsigned char byte)
98 static inline void read_response_byte(void)
101 if ((inb(ipmicsr)>>6) != 1)
107 outb(0x68, ipmidata);
109 /* see if it is done */
110 if ((inb(ipmicsr)>>6) != 1){
111 /* wait for the dummy read. Which describes this protocol */
117 static inline void ipmidelay(void)
120 for(i = 0; i < 1000; i++) {
125 static inline void bmc_foad(void)
128 /* be safe; make sure it is really ready */
129 while ((inb(ipmicsr)>>6)) {
133 first_cmd_byte(nftransport << 2);
143 /* end IPMI garbage */
145 #include "arch/x86/lib/stages.c"
147 static void main(unsigned long bist)
154 static const struct mem_controller mch[] = {
157 /* the wiring on this part is really messed up */
158 /* this is my best guess so far */
159 .channel0 = {DIMM0, DIMM1, DIMM2, DIMM3, },
160 .channel1 = {DIMM4, DIMM5, DIMM6, DIMM7, },
165 /* observed from serialice */
166 static const u8 earlyinit[] = {
175 /* using SerialICE, we've seen this basic reset sequence on the dell.
176 * we don't understand it as it uses undocumented registers, but
177 * we're going to clone it.
179 /* enable a hidden device. */
180 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
182 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
184 /* read-write lock in CMOS on LPC bridge on ICH5 */
185 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd8, 4);
187 /* operate on undocumented device */
188 l = pci_read_config32(PCI_DEV(0, 0, 2), 0xa4);
190 pci_write_config32(PCI_DEV(0, 0, 2), 0xa4, l);
192 l = pci_read_config32(PCI_DEV(0, 0, 2), 0x9c);
194 pci_write_config32(PCI_DEV(0, 0, 2), 0x9c, l);
196 /* disable undocumented device */
197 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
199 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
201 /* set up LPC bridge bits, some of which reply on undocumented
205 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xd8);
207 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd8, b);
209 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xd4);
211 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd4, b);
213 /* ACPI base address */
214 pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x40, 0x800);
216 /* Enable specific ACPI features */
217 b= pci_read_config8(PCI_DEV(0, 0x1f, 0), 0x44);
219 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x44, b);
223 outw(w|0x800, 0x868);
229 dell does this so leave it here so I don't forget
232 pci_write_config16(PCI_DEV(0, 0x1f, 3), 0x20, 0x08c0);
239 /* another device enable? */
240 b = pci_read_config8(PCI_DEV(0, 0, 0), 0xf4);
242 pci_write_config8(PCI_DEV(0, 0, 0), 0xf4, b);
245 l = pci_read_config32(PCI_DEV(0, 8, 0), 0xc0);
246 do_reset = l & 0x8000000;
248 pci_write_config32(PCI_DEV(0, 8, 0), 0xc0, l);
255 /* Skip this if there was a built in self test failure */
257 if (memory_initialized())
260 /* Setup the console */
261 mainboard_set_ich5();
263 pc8374_enable_dev(CONSOLE_SERIAL_DEV, CONFIG_TTYS0_BASE);
267 /* stuff we seem to need */
268 pc8374_enable_dev(PNP_DEV(0x2e, PC8374_KBCK), 0);
271 pc8374_enable_dev(PNP_DEV(0x2e, PC8374_GPIO), 0xc20);
273 /* keep this in mind.
274 SerialICE-hlp: outb 002e <= 23
275 SerialICE-hlp: inb 002f => 05
276 SerialICE-hlp: outb 002f <= 05
277 SerialICE-hlp: outb 002e <= 24
278 SerialICE-hlp: inb 002f => c1
279 SerialICE-hlp: outb 002f <= c1
282 /* Halt if there was a built in self test failure */
283 // report_bist_failure(bist);
285 /* MOVE ME TO A BETTER LOCATION !!! */
286 /* config LPC decode for flash memory access */
288 dev = pci_locate_device(PCI_ID(0x8086, 0x24d0), 0);
289 if (dev == PCI_DEV_INVALID) {
290 die("Missing ich5?");
292 pci_write_config32(dev, 0xe8, 0x00000000);
293 pci_write_config8(dev, 0xf0, 0x00);
296 display_cpuid_update_microcode();
305 // dump_spd_registers(&cpu[0]);
307 for(i = 0; i < 1; i++)
308 dump_spd_registers();
314 // dump_ipmi_registers();
315 mainboard_set_e7520_leds();
317 sdram_initialize(ARRAY_SIZE(mch), mch);
322 dump_pci_device(PCI_DEV(0, 0x00, 0));
323 // dump_bar14(PCI_DEV(0, 0x00, 0));