blob: c254f17b7ee15c438d710b5a93f62c37042b2192 [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.
Thomas Jourdan1a692d82009-07-01 17:01:17 +000016 */
17
Thomas Jourdan1a692d82009-07-01 17:01:17 +000018#include <stdint.h>
Stefan Reinauer069f4762015-01-05 13:02:32 -080019#include <stdlib.h>
Thomas Jourdan1a692d82009-07-01 17:01:17 +000020#include <device/pci_def.h>
Stefan Reinauer069f4762015-01-05 13:02:32 -080021#include <device/pci_ids.h>
22#include <arch/io.h>
Thomas Jourdan1a692d82009-07-01 17:01:17 +000023#include <device/pnp_def.h>
24#include <cpu/x86/lapic.h>
Edwin Beasanteb50c7d2010-07-06 21:05:04 +000025#include <pc80/mc146818rtc.h>
Patrick Georgi12584e22010-05-08 09:14:51 +000026#include <console/console.h>
Stefan Reinauer069f4762015-01-05 13:02:32 -080027#include <delay.h>
Thomas Jourdan1a692d82009-07-01 17:01:17 +000028#include <cpu/x86/bist.h>
Kyösti Mälkki15fa9922016-06-17 10:00:28 +030029#include <cpu/intel/romstage.h>
Nico Huber41392df2012-10-01 15:53:14 +020030#include <cpu/intel/speedstep.h>
stepan836ae292010-12-08 05:42:47 +000031#include "southbridge/intel/i3100/early_smbus.c"
32#include "southbridge/intel/i3100/early_lpc.c"
Stefan Reinauerfa2fc332012-11-13 14:52:04 -080033#include "southbridge/intel/i3100/reset.c"
Edward O'Callaghane64f5b12015-01-04 04:25:38 +110034#include <superio/intel/i3100/i3100.h>
Edward O'Callaghanfdceb482014-06-02 07:58:14 +100035#include <superio/smsc/smscsuperio/smscsuperio.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110036#include <northbridge/intel/i3100/i3100.h>
37#include <southbridge/intel/i3100/i3100.h>
Edward O'Callaghan633f6e32014-11-02 10:17:10 +110038#include "lib/debug.c" // XXX
Thomas Jourdan1a692d82009-07-01 17:01:17 +000039
Thomas Jourdan1a692d82009-07-01 17:01:17 +000040#define DEVPRES_CONFIG (DEVPRES_D1F0 | DEVPRES_D2F0 | DEVPRES_D3F0)
41#define DEVPRES1_CONFIG (DEVPRES1_D0F1 | DEVPRES1_D8F0)
42
Thomas Jourdan1a692d82009-07-01 17:01:17 +000043#define RCBA_RPC 0x0224 /* 32 bit */
44
45#define RCBA_TCTL 0x3000 /* 8 bit */
46
47#define RCBA_D31IP 0x3100 /* 32 bit */
48#define RCBA_D30IP 0x3104 /* 32 bit */
49#define RCBA_D29IP 0x3108 /* 32 bit */
50#define RCBA_D28IP 0x310C /* 32 bit */
51#define RCBA_D31IR 0x3140 /* 16 bit */
52#define RCBA_D30IR 0x3142 /* 16 bit */
53#define RCBA_D29IR 0x3144 /* 16 bit */
54#define RCBA_D28IR 0x3146 /* 16 bit */
55
56#define RCBA_RTC 0x3400 /* 32 bit */
57#define RCBA_HPTC 0x3404 /* 32 bit */
58#define RCBA_GCS 0x3410 /* 32 bit */
59#define RCBA_BUC 0x3414 /* 8 bit */
60#define RCBA_FD 0x3418 /* 32 bit */
61#define RCBA_PRC 0x341C /* 32 bit */
62
Thomas Jourdan1a692d82009-07-01 17:01:17 +000063static inline int spd_read_byte(u16 device, u8 address)
64{
65 return smbus_read_byte(device, address);
66}
67
Edward O'Callaghan77757c22015-01-04 21:33:39 +110068#include <northbridge/intel/i3100/raminit.h>
Thomas Jourdan1a692d82009-07-01 17:01:17 +000069#include "northbridge/intel/i3100/memory_initialized.c"
70#include "northbridge/intel/i3100/raminit.c"
Stefan Reinauerc13093b2009-09-23 18:51:03 +000071#include "lib/generic_sdram.c"
Thomas Jourdan1a692d82009-07-01 17:01:17 +000072#include "northbridge/intel/i3100/reset_test.c"
Uwe Hermann6dc92f02010-11-21 11:36:03 +000073#include <spd.h>
Thomas Jourdan1a692d82009-07-01 17:01:17 +000074
Uwe Hermannd1a1d572010-11-10 18:22:11 +000075#define SERIAL_DEV PNP_DEV(0x4e, I3100_SP1)
76
Stefan Reinauer5d3dee82010-04-14 11:40:34 +000077static void early_config(void)
78{
Thomas Jourdan1a692d82009-07-01 17:01:17 +000079 u32 gcs, rpc, fd;
80
81 /* Enable RCBA */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080082 pci_write_config32(PCI_DEV(0, 0x1F, 0), RCBA, (uintptr_t)DEFAULT_RCBA | 1);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000083
84 /* Disable watchdog */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +000085 gcs = read32(DEFAULT_RCBA + RCBA_GCS);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000086 gcs |= (1 << 5); /* No reset */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +000087 write32(DEFAULT_RCBA + RCBA_GCS, gcs);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000088
89 /* Configure PCIe port B as 4x */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +000090 rpc = read32(DEFAULT_RCBA + RCBA_RPC);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000091 rpc |= (3 << 0);
Stefan Reinauer9fe4d792010-01-16 17:53:38 +000092 write32(DEFAULT_RCBA + RCBA_RPC, rpc);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000093
94 /* Disable Modem, Audio, PCIe ports 2/3/4 */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +000095 fd = read32(DEFAULT_RCBA + RCBA_FD);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000096 fd |= (1 << 19) | (1 << 18) | (1 << 17) | (1 << 6) | (1 << 5);
Stefan Reinauer9fe4d792010-01-16 17:53:38 +000097 write32(DEFAULT_RCBA + RCBA_FD, fd);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000098
99 /* Enable HPET */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000100 write32(DEFAULT_RCBA + RCBA_HPTC, (1 << 7));
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000101
102 /* Improve interrupt routing
103 * D31:F2 SATA INTB# -> PIRQD
104 * D31:F3 SMBUS INTB# -> PIRQD
105 * D31:F4 CHAP INTD# -> PIRQA
106 * D29:F0 USB1#1 INTA# -> PIRQH
107 * D29:F1 USB1#2 INTB# -> PIRQD
108 * D29:F7 USB2 INTA# -> PIRQH
109 * D28:F0 PCIe Port 1 INTA# -> PIRQE
110 */
111
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000112 write16(DEFAULT_RCBA + RCBA_D31IR, 0x0230);
113 write16(DEFAULT_RCBA + RCBA_D30IR, 0x3210);
114 write16(DEFAULT_RCBA + RCBA_D29IR, 0x3237);
115 write16(DEFAULT_RCBA + RCBA_D28IR, 0x3214);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000116
117 /* Setup sata mode */
118 pci_write_config8(PCI_DEV(0, 0x1F, 2), SATA_MAP, (SATA_MODE_AHCI << 6) | (0 << 0));
119}
120
Kyösti Mälkki15fa9922016-06-17 10:00:28 +0300121void mainboard_romstage_entry(unsigned long bist)
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000122{
123 /* int boot_mode = 0; */
124
125 static const struct mem_controller mch[] = {
126 {
127 .node_id = 0,
128 .f0 = PCI_DEV(0, 0x00, 0),
129 .f1 = PCI_DEV(0, 0x00, 1),
130 .f2 = PCI_DEV(0, 0x00, 2),
131 .f3 = PCI_DEV(0, 0x00, 3),
Uwe Hermann6dc92f02010-11-21 11:36:03 +0000132 .channel0 = { DIMM3, DIMM2, DIMM1, DIMM0 },
133 .channel1 = { DIMM7, DIMM6, DIMM5, DIMM4 },
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000134 }
135 };
136
Uwe Hermann7b997052010-11-21 22:47:22 +0000137 if (bist == 0)
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000138 enable_lapic();
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000139
140 /* Setup the console */
141 i3100_enable_superio();
Uwe Hermannd1a1d572010-11-10 18:22:11 +0000142 i3100_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
143 i3100_configure_uart_clk(SERIAL_DEV, I3100_UART_CLK_PREDIVIDE_26);
144
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000145 console_init();
146
147 /* Halt if there was a built in self test failure */
148 report_bist_failure(bist);
149
150 /* Perform early board specific init */
151 early_config();
152
153 /* Prevent the TCO timer from rebooting us */
154 i3100_halt_tco_timer();
155
156 /* Enable SPD ROMs and DDR-II DRAM */
157 enable_smbus();
158
159 /* Enable SpeedStep and automatic thermal throttling */
160 {
161 msr_t msr;
162 u16 perf;
163
164 msr = rdmsr(IA32_MISC_ENABLES);
165 msr.lo |= (1 << 3) | (1 << 16);
166 wrmsr(IA32_MISC_ENABLES, msr);
167
168 /* Set CPU frequency/voltage to maximum */
169
170 /* Read performance status register and keep
171 * bits 47:32, where BUS_RATIO_MAX and VID_MAX
172 * are encoded
173 */
174 msr = rdmsr(IA32_PERF_STS);
175 perf = msr.hi & 0x0000ffff;
176
177 /* Write VID_MAX & BUS_RATIO_MAX to
178 * performance control register
179 */
180 msr = rdmsr(IA32_PERF_CTL);
181 msr.lo &= 0xffff0000;
182 msr.lo |= perf;
183 wrmsr(IA32_PERF_CTL, msr);
184 }
185
186 /* Initialize memory */
187 sdram_initialize(ARRAY_SIZE(mch), mch);
188}