2 * This file is part of the coreboot project.
4 * Copyright (C) 2007-2008 coresystems GmbH
5 * Copyright (C) 2009 Thomas Jourdan <thomas.jourdan@gmail.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
27 #include <arch/romcc_io.h>
28 #include <device/pci_def.h>
29 #include <device/pnp_def.h>
30 #include <cpu/x86/lapic.h>
32 #include <pc80/mc146818rtc.h>
34 #include <console/console.h>
35 #include <cpu/x86/bist.h>
36 #include <cpu/intel/acpi.h>
38 #include "southbridge/intel/i3100/i3100_early_smbus.c"
39 #include "southbridge/intel/i3100/i3100_early_lpc.c"
41 #include "superio/intel/i3100/i3100_early_serial.c"
42 #include "superio/smsc/smscsuperio/smscsuperio_early_serial.c"
43 #include "northbridge/intel/i3100/i3100.h"
44 #include "southbridge/intel/i3100/i3100.h"
46 #define DEVPRES_CONFIG (DEVPRES_D1F0 | DEVPRES_D2F0 | DEVPRES_D3F0)
47 #define DEVPRES1_CONFIG (DEVPRES1_D0F1 | DEVPRES1_D8F0)
49 #define RCBA_RPC 0x0224 /* 32 bit */
51 #define RCBA_TCTL 0x3000 /* 8 bit */
53 #define RCBA_D31IP 0x3100 /* 32 bit */
54 #define RCBA_D30IP 0x3104 /* 32 bit */
55 #define RCBA_D29IP 0x3108 /* 32 bit */
56 #define RCBA_D28IP 0x310C /* 32 bit */
57 #define RCBA_D31IR 0x3140 /* 16 bit */
58 #define RCBA_D30IR 0x3142 /* 16 bit */
59 #define RCBA_D29IR 0x3144 /* 16 bit */
60 #define RCBA_D28IR 0x3146 /* 16 bit */
62 #define RCBA_RTC 0x3400 /* 32 bit */
63 #define RCBA_HPTC 0x3404 /* 32 bit */
64 #define RCBA_GCS 0x3410 /* 32 bit */
65 #define RCBA_BUC 0x3414 /* 8 bit */
66 #define RCBA_FD 0x3418 /* 32 bit */
67 #define RCBA_PRC 0x341C /* 32 bit */
69 static inline int spd_read_byte(u16 device, u8 address)
71 return smbus_read_byte(device, address);
74 #include "northbridge/intel/i3100/raminit.h"
75 #include "cpu/x86/mtrr/earlymtrr.c"
76 #include "northbridge/intel/i3100/memory_initialized.c"
77 #include "northbridge/intel/i3100/raminit.c"
78 #include "lib/generic_sdram.c"
79 #include "northbridge/intel/i3100/reset_test.c"
83 #define SERIAL_DEV PNP_DEV(0x4e, I3100_SP1)
85 static void early_config(void)
90 pci_write_config32(PCI_DEV(0, 0x1F, 0), RCBA, DEFAULT_RCBA | 1);
92 /* Disable watchdog */
93 gcs = read32(DEFAULT_RCBA + RCBA_GCS);
94 gcs |= (1 << 5); /* No reset */
95 write32(DEFAULT_RCBA + RCBA_GCS, gcs);
97 /* Configure PCIe port B as 4x */
98 rpc = read32(DEFAULT_RCBA + RCBA_RPC);
100 write32(DEFAULT_RCBA + RCBA_RPC, rpc);
102 /* Disable Modem, Audio, PCIe ports 2/3/4 */
103 fd = read32(DEFAULT_RCBA + RCBA_FD);
104 fd |= (1 << 19) | (1 << 18) | (1 << 17) | (1 << 6) | (1 << 5);
105 write32(DEFAULT_RCBA + RCBA_FD, fd);
108 write32(DEFAULT_RCBA + RCBA_HPTC, (1 << 7));
110 /* Improve interrupt routing
111 * D31:F2 SATA INTB# -> PIRQD
112 * D31:F3 SMBUS INTB# -> PIRQD
113 * D31:F4 CHAP INTD# -> PIRQA
114 * D29:F0 USB1#1 INTA# -> PIRQH
115 * D29:F1 USB1#2 INTB# -> PIRQD
116 * D29:F7 USB2 INTA# -> PIRQH
117 * D28:F0 PCIe Port 1 INTA# -> PIRQE
120 write16(DEFAULT_RCBA + RCBA_D31IR, 0x0230);
121 write16(DEFAULT_RCBA + RCBA_D30IR, 0x3210);
122 write16(DEFAULT_RCBA + RCBA_D29IR, 0x3237);
123 write16(DEFAULT_RCBA + RCBA_D28IR, 0x3214);
125 /* Setup sata mode */
126 pci_write_config8(PCI_DEV(0, 0x1F, 2), SATA_MAP, (SATA_MODE_AHCI << 6) | (0 << 0));
129 void main(unsigned long bist)
131 /* int boot_mode = 0; */
133 static const struct mem_controller mch[] = {
136 .f0 = PCI_DEV(0, 0x00, 0),
137 .f1 = PCI_DEV(0, 0x00, 1),
138 .f2 = PCI_DEV(0, 0x00, 2),
139 .f3 = PCI_DEV(0, 0x00, 3),
140 .channel0 = { DIMM3, DIMM2, DIMM1, DIMM0 },
141 .channel1 = { DIMM7, DIMM6, DIMM5, DIMM4 },
149 /* Setup the console */
150 i3100_enable_superio();
151 i3100_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
152 i3100_configure_uart_clk(SERIAL_DEV, I3100_UART_CLK_PREDIVIDE_26);
157 /* Halt if there was a built in self test failure */
158 report_bist_failure(bist);
160 /* Perform early board specific init */
163 /* Prevent the TCO timer from rebooting us */
164 i3100_halt_tco_timer();
166 /* Enable SPD ROMs and DDR-II DRAM */
169 /* Enable SpeedStep and automatic thermal throttling */
174 msr = rdmsr(IA32_MISC_ENABLES);
175 msr.lo |= (1 << 3) | (1 << 16);
176 wrmsr(IA32_MISC_ENABLES, msr);
178 /* Set CPU frequency/voltage to maximum */
180 /* Read performance status register and keep
181 * bits 47:32, where BUS_RATIO_MAX and VID_MAX
184 msr = rdmsr(IA32_PERF_STS);
185 perf = msr.hi & 0x0000ffff;
187 /* Write VID_MAX & BUS_RATIO_MAX to
188 * performance control register
190 msr = rdmsr(IA32_PERF_CTL);
191 msr.lo &= 0xffff0000;
193 wrmsr(IA32_PERF_CTL, msr);
196 /* Initialize memory */
197 sdram_initialize(ARRAY_SIZE(mch), mch);