blob: 07ba0a0bdf48ab4f7cd8f13ae1d20eefba67d9e8 [file] [log] [blame]
Thomas Jourdan1a692d82009-07-01 17:01:17 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2008 coresystems GmbH
5 * Copyright (C) 2009 Thomas Jourdan <thomas.jourdan@gmail.com>
6 *
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
10 * the License.
11 *
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.
16 *
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,
20 * MA 02110-1301 USA
21 */
22
Thomas Jourdan1a692d82009-07-01 17:01:17 +000023#include <delay.h>
24
25#include <stdint.h>
26#include <arch/io.h>
27#include <arch/romcc_io.h>
28#include <device/pci_def.h>
29#include <device/pnp_def.h>
30#include <cpu/x86/lapic.h>
31
Edwin Beasanteb50c7d2010-07-06 21:05:04 +000032#include <pc80/mc146818rtc.h>
Thomas Jourdan1a692d82009-07-01 17:01:17 +000033
Patrick Georgi12584e22010-05-08 09:14:51 +000034#include <console/console.h>
Thomas Jourdan1a692d82009-07-01 17:01:17 +000035#include <cpu/x86/bist.h>
Patrick Georgi361bd102010-11-17 21:52:15 +000036#include <cpu/intel/acpi.h>
Thomas Jourdan1a692d82009-07-01 17:01:17 +000037
Thomas Jourdan1a692d82009-07-01 17:01:17 +000038#include "southbridge/intel/i3100/i3100_early_smbus.c"
39#include "southbridge/intel/i3100/i3100_early_lpc.c"
40#include "reset.c"
41#include "superio/intel/i3100/i3100_early_serial.c"
42#include "superio/smsc/smscsuperio/smscsuperio_early_serial.c"
Patrick Georgic2bf26d2010-11-15 19:44:42 +000043#include "northbridge/intel/i3100/i3100.h"
Patrick Georgi9e180382010-11-18 10:48:15 +000044#include "southbridge/intel/i3100/i3100.h"
Thomas Jourdan1a692d82009-07-01 17:01:17 +000045
Thomas Jourdan1a692d82009-07-01 17:01:17 +000046#define DEVPRES_CONFIG (DEVPRES_D1F0 | DEVPRES_D2F0 | DEVPRES_D3F0)
47#define DEVPRES1_CONFIG (DEVPRES1_D0F1 | DEVPRES1_D8F0)
48
Thomas Jourdan1a692d82009-07-01 17:01:17 +000049#define RCBA_RPC 0x0224 /* 32 bit */
50
51#define RCBA_TCTL 0x3000 /* 8 bit */
52
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 */
61
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 */
68
Thomas Jourdan1a692d82009-07-01 17:01:17 +000069static inline int spd_read_byte(u16 device, u8 address)
70{
71 return smbus_read_byte(device, address);
72}
73
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"
Stefan Reinauerc13093b2009-09-23 18:51:03 +000078#include "lib/generic_sdram.c"
Thomas Jourdan1a692d82009-07-01 17:01:17 +000079#include "northbridge/intel/i3100/reset_test.c"
80#include "debug.c"
81
Uwe Hermannd1a1d572010-11-10 18:22:11 +000082#define SERIAL_DEV PNP_DEV(0x4e, I3100_SP1)
83
Stefan Reinauer5d3dee82010-04-14 11:40:34 +000084static void early_config(void)
85{
Thomas Jourdan1a692d82009-07-01 17:01:17 +000086 u32 gcs, rpc, fd;
87
88 /* Enable RCBA */
89 pci_write_config32(PCI_DEV(0, 0x1F, 0), RCBA, DEFAULT_RCBA | 1);
90
91 /* Disable watchdog */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +000092 gcs = read32(DEFAULT_RCBA + RCBA_GCS);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000093 gcs |= (1 << 5); /* No reset */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +000094 write32(DEFAULT_RCBA + RCBA_GCS, gcs);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000095
96 /* Configure PCIe port B as 4x */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +000097 rpc = read32(DEFAULT_RCBA + RCBA_RPC);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000098 rpc |= (3 << 0);
Stefan Reinauer9fe4d792010-01-16 17:53:38 +000099 write32(DEFAULT_RCBA + RCBA_RPC, rpc);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000100
101 /* Disable Modem, Audio, PCIe ports 2/3/4 */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000102 fd = read32(DEFAULT_RCBA + RCBA_FD);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000103 fd |= (1 << 19) | (1 << 18) | (1 << 17) | (1 << 6) | (1 << 5);
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000104 write32(DEFAULT_RCBA + RCBA_FD, fd);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000105
106 /* Enable HPET */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000107 write32(DEFAULT_RCBA + RCBA_HPTC, (1 << 7));
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000108
109 /* Improve interrupt routing
110 * D31:F2 SATA INTB# -> PIRQD
111 * D31:F3 SMBUS INTB# -> PIRQD
112 * D31:F4 CHAP INTD# -> PIRQA
113 * D29:F0 USB1#1 INTA# -> PIRQH
114 * D29:F1 USB1#2 INTB# -> PIRQD
115 * D29:F7 USB2 INTA# -> PIRQH
116 * D28:F0 PCIe Port 1 INTA# -> PIRQE
117 */
118
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000119 write16(DEFAULT_RCBA + RCBA_D31IR, 0x0230);
120 write16(DEFAULT_RCBA + RCBA_D30IR, 0x3210);
121 write16(DEFAULT_RCBA + RCBA_D29IR, 0x3237);
122 write16(DEFAULT_RCBA + RCBA_D28IR, 0x3214);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000123
124 /* Setup sata mode */
125 pci_write_config8(PCI_DEV(0, 0x1F, 2), SATA_MAP, (SATA_MODE_AHCI << 6) | (0 << 0));
126}
127
Stefan Reinauer6d1b0d82010-04-13 00:02:20 +0000128void main(unsigned long bist)
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000129{
130 /* int boot_mode = 0; */
131
132 static const struct mem_controller mch[] = {
133 {
134 .node_id = 0,
135 .f0 = PCI_DEV(0, 0x00, 0),
136 .f1 = PCI_DEV(0, 0x00, 1),
137 .f2 = PCI_DEV(0, 0x00, 2),
138 .f3 = PCI_DEV(0, 0x00, 3),
139 .channel0 = { (0xa<<3)|3, (0xa<<3)|2, (0xa<<3)|1, (0xa<<3)|0 },
140 .channel1 = { (0xa<<3)|7, (0xa<<3)|6, (0xa<<3)|5, (0xa<<3)|4 },
141 }
142 };
143
144 if (bist == 0) {
145 enable_lapic();
146 }
147
148 /* Setup the console */
149 i3100_enable_superio();
Uwe Hermannd1a1d572010-11-10 18:22:11 +0000150 i3100_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
151 i3100_configure_uart_clk(SERIAL_DEV, I3100_UART_CLK_PREDIVIDE_26);
152
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000153 uart_init();
154 console_init();
155
156 /* Halt if there was a built in self test failure */
157 report_bist_failure(bist);
158
159 /* Perform early board specific init */
160 early_config();
161
162 /* Prevent the TCO timer from rebooting us */
163 i3100_halt_tco_timer();
164
165 /* Enable SPD ROMs and DDR-II DRAM */
166 enable_smbus();
167
168 /* Enable SpeedStep and automatic thermal throttling */
169 {
170 msr_t msr;
171 u16 perf;
172
173 msr = rdmsr(IA32_MISC_ENABLES);
174 msr.lo |= (1 << 3) | (1 << 16);
175 wrmsr(IA32_MISC_ENABLES, msr);
176
177 /* Set CPU frequency/voltage to maximum */
178
179 /* Read performance status register and keep
180 * bits 47:32, where BUS_RATIO_MAX and VID_MAX
181 * are encoded
182 */
183 msr = rdmsr(IA32_PERF_STS);
184 perf = msr.hi & 0x0000ffff;
185
186 /* Write VID_MAX & BUS_RATIO_MAX to
187 * performance control register
188 */
189 msr = rdmsr(IA32_PERF_CTL);
190 msr.lo &= 0xffff0000;
191 msr.lo |= perf;
192 wrmsr(IA32_PERF_CTL, msr);
193 }
194
195 /* Initialize memory */
196 sdram_initialize(ARRAY_SIZE(mch), mch);
197}
198