blob: e3063b2ce002d481b3a3012b12c9cfbcc7107601 [file] [log] [blame]
Stefan Reinauer36a22682008-10-29 04:52:57 +00001/*
2 * This file is part of the coreboot project.
Stefan Reinauer14e22772010-04-27 06:56:47 +00003 *
Stefan Reinauerde3206a2010-02-22 06:09:43 +00004 * Copyright (C) 2007-2010 coresystems GmbH
Stefan Reinauer36a22682008-10-29 04:52:57 +00005 *
Uwe Hermann2bb4acf2010-03-01 17:19:55 +00006 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
Stefan Reinauer36a22682008-10-29 04:52:57 +00009 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Stefan Reinauer36a22682008-10-29 04:52:57 +000014 */
15
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020016/* __PRE_RAM__ means: use "unsigned" for device, not a struct. */
Stefan Reinauer5e328232010-03-29 19:19:16 +000017
Stefan Reinauer36a22682008-10-29 04:52:57 +000018#include <stdint.h>
Patrick Georgi12aba822009-04-30 07:07:22 +000019#include <string.h>
Patrick Georgid0835952010-10-05 09:07:10 +000020#include <lib.h>
Kyösti Mälkki12d681b2014-06-14 18:51:34 +030021#include <arch/acpi.h>
Kyösti Mälkkia7c96112013-10-13 20:41:57 +030022#include <cbmem.h>
Stefan Reinauer36a22682008-10-29 04:52:57 +000023#include <arch/io.h>
Stefan Reinauer36a22682008-10-29 04:52:57 +000024#include <device/pci_def.h>
25#include <device/pnp_def.h>
26#include <cpu/x86/lapic.h>
Edwin Beasanteb50c7d2010-07-06 21:05:04 +000027#include <pc80/mc146818rtc.h>
Stefan Reinauer10ec0fe2010-09-25 10:40:47 +000028#include "option_table.h"
Stefan Reinauerde3206a2010-02-22 06:09:43 +000029#include <console/console.h>
Stefan Reinauer36a22682008-10-29 04:52:57 +000030#include <cpu/x86/bist.h>
Kyösti Mälkki15fa9922016-06-17 10:00:28 +030031#include <cpu/intel/romstage.h>
Patrick Georgi546953c2014-11-29 10:38:17 +010032#include <halt.h>
Edward O'Callaghan4f5a5252014-04-03 14:40:24 +110033#include <superio/winbond/w83627thg/w83627thg.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110034#include <northbridge/intel/i945/i945.h>
35#include <northbridge/intel/i945/raminit.h>
36#include <southbridge/intel/i82801gx/i82801gx.h>
Patrick Georgid0835952010-10-05 09:07:10 +000037
Uwe Hermann57b2ff82010-11-21 17:29:59 +000038#define SERIAL_DEV PNP_DEV(0x2e, W83627THG_SP1)
39
Patrick Georgid0835952010-10-05 09:07:10 +000040void setup_ich7_gpios(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000041{
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000042 printk(BIOS_DEBUG, " GPIOS...");
Stefan Reinauer36a22682008-10-29 04:52:57 +000043 /* General Registers */
44 outl(0x1f1ff7c0, DEFAULT_GPIOBASE + 0x00); /* GPIO_USE_SEL */
45 outl(0xe0e8efc3, DEFAULT_GPIOBASE + 0x04); /* GP_IO_SEL */
46 outl(0xebffeeff, DEFAULT_GPIOBASE + 0x0c); /* GP_LVL */
47 /* Output Control Registers */
48 outl(0x00000000, DEFAULT_GPIOBASE + 0x18); /* GPO_BLINK */
49 /* Input Control Registers */
50 outl(0x00002180, DEFAULT_GPIOBASE + 0x2c); /* GPI_INV */
Stefan Reinauere1025d02009-03-11 15:20:36 +000051 outl(0x000100ff, DEFAULT_GPIOBASE + 0x30); /* GPIO_USE_SEL2 */
Stefan Reinauer36a22682008-10-29 04:52:57 +000052 outl(0x00000030, DEFAULT_GPIOBASE + 0x34); /* GP_IO_SEL2 */
53 outl(0x00010035, DEFAULT_GPIOBASE + 0x38); /* GP_LVL */
54}
55
Stefan Reinauer36a22682008-10-29 04:52:57 +000056static void ich7_enable_lpc(void)
57{
Patrick Georgia4700192011-01-27 07:39:38 +000058 int lpt_en = 0;
Patrick Georgib2517532011-05-10 21:53:13 +000059 if (read_option(lpt, 0) != 0) {
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020060 lpt_en = 1 << 2; /* enable LPT */
Patrick Georgia4700192011-01-27 07:39:38 +000061 }
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020062 /* Enable Serial IRQ */
Stefan Reinauer36a22682008-10-29 04:52:57 +000063 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x64, 0xd0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020064 /* Set COM1/COM2 decode range */
Stefan Reinauer36a22682008-10-29 04:52:57 +000065 pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x80, 0x0010);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020066 /* Enable COM1/COM2/KBD/SuperIO1+2 */
Patrick Georgia4700192011-01-27 07:39:38 +000067 pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x340b | lpt_en);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020068 /* Enable HWM at 0xa00 */
Stefan Reinauere1025d02009-03-11 15:20:36 +000069 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x84, 0x00fc0a01);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020070 /* COM3 decode */
Stefan Reinauer36a22682008-10-29 04:52:57 +000071 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x88, 0x000403e9);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020072 /* COM4 decode */
Stefan Reinauer36a22682008-10-29 04:52:57 +000073 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x8c, 0x000402e9);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020074 /* io 0x300 decode */
Stefan Reinauer36a22682008-10-29 04:52:57 +000075 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x90, 0x00000301);
76}
77
Edward O'Callaghan2c55b702014-05-13 23:29:22 +100078/* TODO: superio code should really not be in mainboard */
79static void pnp_enter_func_mode(device_t dev)
80{
81 u16 port = dev >> 8;
82 outb(0x87, port);
83 outb(0x87, port);
84}
85
86static void pnp_exit_func_mode(device_t dev)
87{
88 u16 port = dev >> 8;
89 outb(0xaa, port);
90}
91
Stefan Reinauer36a22682008-10-29 04:52:57 +000092/* This box has two superios, so enabling serial becomes slightly excessive.
93 * We disable a lot of stuff to make sure that there are no conflicts between
94 * the two. Also set up the GPIOs from the beginning. This is the "no schematic
95 * but safe anyways" method.
96 */
97static void early_superio_config_w83627thg(void)
98{
99 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000100
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600101 dev = PNP_DEV(0x2e, W83627THG_SP1);
Edward O'Callaghan2c55b702014-05-13 23:29:22 +1000102 pnp_enter_func_mode(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000103
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200104 pnp_write_config(dev, 0x24, 0xc6); /* PNPCSV */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000105
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200106 pnp_write_config(dev, 0x29, 0x43); /* GPIO settings */
107 pnp_write_config(dev, 0x2a, 0x40); /* GPIO settings */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000108
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600109 dev = PNP_DEV(0x2e, W83627THG_SP1);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000110 pnp_set_logical_device(dev);
111 pnp_set_enable(dev, 0);
112 pnp_set_iobase(dev, PNP_IDX_IO0, 0x3f8);
113 pnp_set_irq(dev, PNP_IDX_IRQ0, 4);
114 pnp_set_enable(dev, 1);
115
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600116 dev = PNP_DEV(0x2e, W83627THG_SP2);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000117 pnp_set_logical_device(dev);
118 pnp_set_enable(dev, 0);
119 pnp_set_iobase(dev, PNP_IDX_IO0, 0x2f8);
120 pnp_set_irq(dev, PNP_IDX_IRQ0, 3);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000121 pnp_set_enable(dev, 1);
122
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600123 dev = PNP_DEV(0x2e, W83627THG_KBC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000124 pnp_set_logical_device(dev);
125 pnp_set_enable(dev, 0);
126 pnp_set_iobase(dev, PNP_IDX_IO0, 0x60);
127 pnp_set_iobase(dev, PNP_IDX_IO1, 0x64);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000128 pnp_set_enable(dev, 1);
129
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600130 dev = PNP_DEV(0x2e, W83627THG_GAME_MIDI_GPIO1);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000131 pnp_set_logical_device(dev);
132 pnp_set_enable(dev, 0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200133 pnp_write_config(dev, 0xf5, 0xff); /* invert all GPIOs */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000134 pnp_set_enable(dev, 1);
135
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600136 dev = PNP_DEV(0x2e, W83627THG_GPIO2);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000137 pnp_set_logical_device(dev);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200138 pnp_set_enable(dev, 1); /* Just enable it */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000139
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600140 dev = PNP_DEV(0x2e, W83627THG_GPIO3);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000141 pnp_set_logical_device(dev);
142 pnp_set_enable(dev, 0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200143 pnp_write_config(dev, 0xf0, 0xfb); /* GPIO bit 2 is output */
144 pnp_write_config(dev, 0xf1, 0x00); /* GPIO bit 2 is 0 */
145 pnp_write_config(dev, 0x30, 0x03); /* Enable GPIO3+4. pnp_set_enable is not sufficient */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000146
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600147 dev = PNP_DEV(0x2e, W83627THG_FDC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000148 pnp_set_logical_device(dev);
149 pnp_set_enable(dev, 0);
150
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600151 dev = PNP_DEV(0x2e, W83627THG_PP);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000152 pnp_set_logical_device(dev);
153 pnp_set_enable(dev, 0);
154
Stefan Reinauer54309d62009-01-20 22:53:10 +0000155 /* Enable HWM */
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600156 dev = PNP_DEV(0x2e, W83627THG_HWM);
Stefan Reinauer54309d62009-01-20 22:53:10 +0000157 pnp_set_logical_device(dev);
158 pnp_set_enable(dev, 0);
159 pnp_set_iobase(dev, PNP_IDX_IO0, 0xa00);
160 pnp_set_enable(dev, 1);
161
Edward O'Callaghan2c55b702014-05-13 23:29:22 +1000162 pnp_exit_func_mode(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000163
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600164 dev = PNP_DEV(0x4e, W83627THG_SP1);
Edward O'Callaghan2c55b702014-05-13 23:29:22 +1000165 pnp_enter_func_mode(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000166
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200167 pnp_set_logical_device(dev); /* Set COM3 to sane non-conflicting values */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000168 pnp_set_enable(dev, 0);
169 pnp_set_iobase(dev, PNP_IDX_IO0, 0x3e8);
170 pnp_set_irq(dev, PNP_IDX_IRQ0, 11);
171 pnp_set_enable(dev, 1);
172
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600173 dev = PNP_DEV(0x4e, W83627THG_SP2);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200174 pnp_set_logical_device(dev); /* Set COM4 to sane non-conflicting values */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000175 pnp_set_enable(dev, 0);
176 pnp_set_iobase(dev, PNP_IDX_IO0, 0x2e8);
177 pnp_set_irq(dev, PNP_IDX_IRQ0, 10);
178 pnp_set_enable(dev, 1);
179
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600180 dev = PNP_DEV(0x4e, W83627THG_FDC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000181 pnp_set_logical_device(dev);
182 pnp_set_enable(dev, 0);
183
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600184 dev = PNP_DEV(0x4e, W83627THG_PP);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000185 pnp_set_logical_device(dev);
186 pnp_set_enable(dev, 0);
187
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600188 dev = PNP_DEV(0x4e, W83627THG_KBC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000189 pnp_set_logical_device(dev);
190 pnp_set_enable(dev, 0);
191 pnp_set_iobase(dev, PNP_IDX_IO0, 0x00);
192 pnp_set_iobase(dev, PNP_IDX_IO1, 0x00);
193
Edward O'Callaghan2c55b702014-05-13 23:29:22 +1000194 pnp_exit_func_mode(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000195}
196
197static void rcba_config(void)
198{
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000199 u32 reg32;
200
Stefan Reinauer36a22682008-10-29 04:52:57 +0000201 /* Set up virtual channel 0 */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000202
203 /* Device 1f interrupt pin register */
204 RCBA32(0x3100) = 0x00042210;
205 /* Device 1d interrupt pin register */
206 RCBA32(0x310c) = 0x00214321;
207
208 /* dev irq route register */
209 RCBA16(0x3140) = 0x0132;
210 RCBA16(0x3142) = 0x3241;
211 RCBA16(0x3144) = 0x0237;
212 RCBA16(0x3146) = 0x3210;
213 RCBA16(0x3148) = 0x3210;
214
215 /* Enable IOAPIC */
216 RCBA8(0x31ff) = 0x03;
217
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000218 /* Now, this is a bit ugly. As per PCI specification, function 0 of a
219 * device always has to be implemented. So disabling ethernet port 1
220 * would essentially disable all three ethernet ports of the mainboard.
221 * It's possible to rename the ports to achieve compatibility to the
222 * PCI spec but this will confuse all (static!) tables containing
Stefan Reinauer14e22772010-04-27 06:56:47 +0000223 * interrupt routing information.
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000224 * To avoid this, we enable (unused) port 6 and swap it with port 1
225 * in the case that ethernet port 1 is disabled. Since no devices
226 * are connected to that port, we don't have to worry about interrupt
227 * routing.
228 */
229 int port_shuffle = 0;
230
Stefan Reinauer36a22682008-10-29 04:52:57 +0000231 /* Disable unused devices */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000232 reg32 = FD_ACMOD|FD_ACAUD|FD_PATA;
233 reg32 |= FD_PCIE6|FD_PCIE5|FD_PCIE4;
234
Patrick Georgib2517532011-05-10 21:53:13 +0000235 if (read_option(ethernet1, 0) != 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000236 printk(BIOS_DEBUG, "Disabling ethernet adapter 1.\n");
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000237 reg32 |= FD_PCIE1;
238 }
Patrick Georgib2517532011-05-10 21:53:13 +0000239 if (read_option(ethernet2, 0) != 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000240 printk(BIOS_DEBUG, "Disabling ethernet adapter 2.\n");
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000241 reg32 |= FD_PCIE2;
242 } else {
243 if (reg32 & FD_PCIE1)
244 port_shuffle = 1;
245 }
Patrick Georgib2517532011-05-10 21:53:13 +0000246 if (read_option(ethernet3, 0) != 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000247 printk(BIOS_DEBUG, "Disabling ethernet adapter 3.\n");
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000248 reg32 |= FD_PCIE3;
249 } else {
250 if (reg32 & FD_PCIE1)
251 port_shuffle = 1;
252 }
253
254 if (port_shuffle) {
255 /* Enable PCIE6 again */
256 reg32 &= ~FD_PCIE6;
257 /* Swap PCIE6 and PCIE1 */
258 RCBA32(RPFN) = 0x00043215;
259 }
260
261 reg32 |= 1;
262
263 RCBA32(0x3418) = reg32;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000264
265 /* Enable PCIe Root Port Clock Gate */
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200266
Stefan Reinauer36a22682008-10-29 04:52:57 +0000267}
268
269static void early_ich7_init(void)
270{
271 uint8_t reg8;
272 uint32_t reg32;
273
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200274 /* program secondary mlt XXX byte? */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000275 pci_write_config8(PCI_DEV(0, 0x1e, 0), 0x1b, 0x20);
276
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200277 /* reset rtc power status */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000278 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa4);
279 reg8 &= ~(1 << 2);
280 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xa4, reg8);
281
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200282 /* usb transient disconnect */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000283 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xad);
284 reg8 |= (3 << 0);
285 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xad, reg8);
286
287 reg32 = pci_read_config32(PCI_DEV(0, 0x1d, 7), 0xfc);
288 reg32 |= (1 << 29) | (1 << 17);
289 pci_write_config32(PCI_DEV(0, 0x1d, 7), 0xfc, reg32);
290
291 reg32 = pci_read_config32(PCI_DEV(0, 0x1d, 7), 0xdc);
292 reg32 |= (1 << 31) | (1 << 27);
293 pci_write_config32(PCI_DEV(0, 0x1d, 7), 0xdc, reg32);
294
295 RCBA32(0x0088) = 0x0011d000;
296 RCBA16(0x01fc) = 0x060f;
297 RCBA32(0x01f4) = 0x86000040;
298 RCBA32(0x0214) = 0x10030549;
299 RCBA32(0x0218) = 0x00020504;
300 RCBA8(0x0220) = 0xc5;
301 reg32 = RCBA32(0x3410);
302 reg32 |= (1 << 6);
303 RCBA32(0x3410) = reg32;
304 reg32 = RCBA32(0x3430);
305 reg32 &= ~(3 << 0);
306 reg32 |= (1 << 0);
307 RCBA32(0x3430) = reg32;
308 RCBA32(0x3418) |= (1 << 0);
309 RCBA16(0x0200) = 0x2008;
310 RCBA8(0x2027) = 0x0d;
311 RCBA16(0x3e08) |= (1 << 7);
312 RCBA16(0x3e48) |= (1 << 7);
313 RCBA32(0x3e0e) |= (1 << 7);
314 RCBA32(0x3e4e) |= (1 << 7);
315
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200316 /* next step only on ich7m b0 and later: */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000317 reg32 = RCBA32(0x2034);
318 reg32 &= ~(0x0f << 16);
319 reg32 |= (5 << 16);
320 RCBA32(0x2034) = reg32;
321}
322
Kyösti Mälkki15fa9922016-06-17 10:00:28 +0300323void mainboard_romstage_entry(unsigned long bist)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000324{
Vladimir Serbinenko55601882014-10-15 20:17:51 +0200325 int s3resume = 0;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000326
Uwe Hermann7b997052010-11-21 22:47:22 +0000327 if (bist == 0)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000328 enable_lapic();
Stefan Reinauer36a22682008-10-29 04:52:57 +0000329
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000330 /* Force PCIRST# */
331 pci_write_config16(PCI_DEV(0, 0x1e, 0), BCTRL, SBR);
Stefan Reinauerbc8613e2010-08-25 18:35:42 +0000332 udelay(200 * 1000);
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000333 pci_write_config16(PCI_DEV(0, 0x1e, 0), BCTRL, 0);
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000334
Stefan Reinauerbc8613e2010-08-25 18:35:42 +0000335 ich7_enable_lpc();
Stefan Reinauer36a22682008-10-29 04:52:57 +0000336 early_superio_config_w83627thg();
337
338 /* Set up the console */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000339 console_init();
340
341 /* Halt if there was a built in self test failure */
342 report_bist_failure(bist);
343
344 if (MCHBAR16(SSKPD) == 0xCAFE) {
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000345 printk(BIOS_DEBUG, "soft reset detected, rebooting properly\n");
346 outb(0x6, 0xcf9);
Patrick Georgi546953c2014-11-29 10:38:17 +0100347 halt();
Stefan Reinauer36a22682008-10-29 04:52:57 +0000348 }
349
350 /* Perform some early chipset initialization required
351 * before RAM initialization can work
352 */
353 i945_early_initialization();
354
Vladimir Serbinenko55601882014-10-15 20:17:51 +0200355 s3resume = southbridge_detect_s3_resume();
Stefan Reinauera5fdadf2009-07-21 21:58:20 +0000356
Stefan Reinauer36a22682008-10-29 04:52:57 +0000357 /* Enable SPD ROMs and DDR-II DRAM */
358 enable_smbus();
Stefan Reinauer14e22772010-04-27 06:56:47 +0000359
Stefan Reinauer08670622009-06-30 15:17:49 +0000360#if CONFIG_DEFAULT_CONSOLE_LOGLEVEL > 8
Stefan Reinauer36a22682008-10-29 04:52:57 +0000361 dump_spd_registers();
362#endif
363
Vladimir Serbinenko55601882014-10-15 20:17:51 +0200364 sdram_initialize(s3resume ? 2 : 0, NULL);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000365
366 /* Perform some initialization that must run before stage2 */
367 early_ich7_init();
368
Stefan Reinauer14e22772010-04-27 06:56:47 +0000369 /* This should probably go away. Until now it is required
370 * and mainboard specific
Stefan Reinauer36a22682008-10-29 04:52:57 +0000371 */
372 rcba_config();
373
374 /* Chipset Errata! */
375 fixup_i945_errata();
376
377 /* Initialize the internal PCIe links before we go into stage2 */
Vladimir Serbinenko55601882014-10-15 20:17:51 +0200378 i945_late_initialization(s3resume);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000379}