blob: f7e8131a5e7230a0b595356b6c4911aa0ec99bac [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>
Paul Menzel6c20b652016-12-29 22:54:02 +010023#include <timestamp.h>
Stefan Reinauer36a22682008-10-29 04:52:57 +000024#include <arch/io.h>
Stefan Reinauer36a22682008-10-29 04:52:57 +000025#include <device/pci_def.h>
26#include <device/pnp_def.h>
27#include <cpu/x86/lapic.h>
Edwin Beasanteb50c7d2010-07-06 21:05:04 +000028#include <pc80/mc146818rtc.h>
Stefan Reinauer10ec0fe2010-09-25 10:40:47 +000029#include "option_table.h"
Stefan Reinauerde3206a2010-02-22 06:09:43 +000030#include <console/console.h>
Stefan Reinauer36a22682008-10-29 04:52:57 +000031#include <cpu/x86/bist.h>
Kyösti Mälkki15fa9922016-06-17 10:00:28 +030032#include <cpu/intel/romstage.h>
Patrick Georgi546953c2014-11-29 10:38:17 +010033#include <halt.h>
Edward O'Callaghan4f5a5252014-04-03 14:40:24 +110034#include <superio/winbond/w83627thg/w83627thg.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110035#include <northbridge/intel/i945/i945.h>
36#include <northbridge/intel/i945/raminit.h>
37#include <southbridge/intel/i82801gx/i82801gx.h>
Patrick Georgid0835952010-10-05 09:07:10 +000038
Uwe Hermann57b2ff82010-11-21 17:29:59 +000039#define SERIAL_DEV PNP_DEV(0x2e, W83627THG_SP1)
40
Stefan Reinauer36a22682008-10-29 04:52:57 +000041static void ich7_enable_lpc(void)
42{
Patrick Georgia4700192011-01-27 07:39:38 +000043 int lpt_en = 0;
Arthur Heymansb451df22017-08-15 20:59:09 +020044 if (read_option(lpt, 0) != 0)
45 lpt_en = LPT_LPC_EN; /* enable LPT */
46
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020047 /* Enable Serial IRQ */
Arthur Heymansb451df22017-08-15 20:59:09 +020048 pci_write_config8(PCI_DEV(0, 0x1f, 0), SERIRQ_CNTL, 0xd0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020049 /* Set COM1/COM2 decode range */
Arthur Heymansb451df22017-08-15 20:59:09 +020050 pci_write_config16(PCI_DEV(0, 0x1f, 0), LPC_IO_DEC, 0x0010);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020051 /* Enable COM1/COM2/KBD/SuperIO1+2 */
Arthur Heymansb451df22017-08-15 20:59:09 +020052 pci_write_config16(PCI_DEV(0, 0x1f, 0), LPC_EN, CNF2_LPC_EN
53 | CNF1_LPC_EN | KBC_LPC_EN | FDD_LPC_EN | COMA_LPC_EN
54 | COMB_LPC_EN | lpt_en);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020055 /* Enable HWM at 0xa00 */
Arthur Heymansb451df22017-08-15 20:59:09 +020056 pci_write_config32(PCI_DEV(0, 0x1f, 0), GEN1_DEC, 0x00fc0a01);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020057 /* COM3 decode */
Arthur Heymansb451df22017-08-15 20:59:09 +020058 pci_write_config32(PCI_DEV(0, 0x1f, 0), GEN2_DEC, 0x000403e9);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020059 /* COM4 decode */
Arthur Heymansb451df22017-08-15 20:59:09 +020060 pci_write_config32(PCI_DEV(0, 0x1f, 0), GEN3_DEC, 0x000402e9);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020061 /* io 0x300 decode */
Arthur Heymansb451df22017-08-15 20:59:09 +020062 pci_write_config32(PCI_DEV(0, 0x1f, 0), GEN4_DEC, 0x00000301);
Stefan Reinauer36a22682008-10-29 04:52:57 +000063}
64
Edward O'Callaghan2c55b702014-05-13 23:29:22 +100065/* TODO: superio code should really not be in mainboard */
Antonello Dettori9ec11232016-11-08 18:44:46 +010066static void pnp_enter_func_mode(pnp_devfn_t dev)
Edward O'Callaghan2c55b702014-05-13 23:29:22 +100067{
68 u16 port = dev >> 8;
69 outb(0x87, port);
70 outb(0x87, port);
71}
72
Antonello Dettori9ec11232016-11-08 18:44:46 +010073static void pnp_exit_func_mode(pnp_devfn_t dev)
Edward O'Callaghan2c55b702014-05-13 23:29:22 +100074{
75 u16 port = dev >> 8;
76 outb(0xaa, port);
77}
78
Stefan Reinauer36a22682008-10-29 04:52:57 +000079/* This box has two superios, so enabling serial becomes slightly excessive.
80 * We disable a lot of stuff to make sure that there are no conflicts between
81 * the two. Also set up the GPIOs from the beginning. This is the "no schematic
82 * but safe anyways" method.
83 */
84static void early_superio_config_w83627thg(void)
85{
Antonello Dettori9ec11232016-11-08 18:44:46 +010086 pnp_devfn_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000087
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060088 dev = PNP_DEV(0x2e, W83627THG_SP1);
Edward O'Callaghan2c55b702014-05-13 23:29:22 +100089 pnp_enter_func_mode(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +000090
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020091 pnp_write_config(dev, 0x24, 0xc6); /* PNPCSV */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +000092
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020093 pnp_write_config(dev, 0x29, 0x43); /* GPIO settings */
94 pnp_write_config(dev, 0x2a, 0x40); /* GPIO settings */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +000095
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060096 dev = PNP_DEV(0x2e, W83627THG_SP1);
Stefan Reinauer36a22682008-10-29 04:52:57 +000097 pnp_set_logical_device(dev);
98 pnp_set_enable(dev, 0);
99 pnp_set_iobase(dev, PNP_IDX_IO0, 0x3f8);
100 pnp_set_irq(dev, PNP_IDX_IRQ0, 4);
101 pnp_set_enable(dev, 1);
102
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600103 dev = PNP_DEV(0x2e, W83627THG_SP2);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000104 pnp_set_logical_device(dev);
105 pnp_set_enable(dev, 0);
106 pnp_set_iobase(dev, PNP_IDX_IO0, 0x2f8);
107 pnp_set_irq(dev, PNP_IDX_IRQ0, 3);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000108 pnp_set_enable(dev, 1);
109
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600110 dev = PNP_DEV(0x2e, W83627THG_KBC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000111 pnp_set_logical_device(dev);
112 pnp_set_enable(dev, 0);
113 pnp_set_iobase(dev, PNP_IDX_IO0, 0x60);
114 pnp_set_iobase(dev, PNP_IDX_IO1, 0x64);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000115 pnp_set_enable(dev, 1);
116
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600117 dev = PNP_DEV(0x2e, W83627THG_GAME_MIDI_GPIO1);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000118 pnp_set_logical_device(dev);
119 pnp_set_enable(dev, 0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200120 pnp_write_config(dev, 0xf5, 0xff); /* invert all GPIOs */
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_GPIO2);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000124 pnp_set_logical_device(dev);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200125 pnp_set_enable(dev, 1); /* Just enable it */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000126
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600127 dev = PNP_DEV(0x2e, W83627THG_GPIO3);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000128 pnp_set_logical_device(dev);
129 pnp_set_enable(dev, 0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200130 pnp_write_config(dev, 0xf0, 0xfb); /* GPIO bit 2 is output */
131 pnp_write_config(dev, 0xf1, 0x00); /* GPIO bit 2 is 0 */
132 pnp_write_config(dev, 0x30, 0x03); /* Enable GPIO3+4. pnp_set_enable is not sufficient */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000133
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600134 dev = PNP_DEV(0x2e, W83627THG_FDC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000135 pnp_set_logical_device(dev);
136 pnp_set_enable(dev, 0);
137
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600138 dev = PNP_DEV(0x2e, W83627THG_PP);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000139 pnp_set_logical_device(dev);
140 pnp_set_enable(dev, 0);
141
Stefan Reinauer54309d62009-01-20 22:53:10 +0000142 /* Enable HWM */
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600143 dev = PNP_DEV(0x2e, W83627THG_HWM);
Stefan Reinauer54309d62009-01-20 22:53:10 +0000144 pnp_set_logical_device(dev);
145 pnp_set_enable(dev, 0);
146 pnp_set_iobase(dev, PNP_IDX_IO0, 0xa00);
147 pnp_set_enable(dev, 1);
148
Edward O'Callaghan2c55b702014-05-13 23:29:22 +1000149 pnp_exit_func_mode(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000150
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600151 dev = PNP_DEV(0x4e, W83627THG_SP1);
Edward O'Callaghan2c55b702014-05-13 23:29:22 +1000152 pnp_enter_func_mode(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000153
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200154 pnp_set_logical_device(dev); /* Set COM3 to sane non-conflicting values */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000155 pnp_set_enable(dev, 0);
156 pnp_set_iobase(dev, PNP_IDX_IO0, 0x3e8);
157 pnp_set_irq(dev, PNP_IDX_IRQ0, 11);
158 pnp_set_enable(dev, 1);
159
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600160 dev = PNP_DEV(0x4e, W83627THG_SP2);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200161 pnp_set_logical_device(dev); /* Set COM4 to sane non-conflicting values */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000162 pnp_set_enable(dev, 0);
163 pnp_set_iobase(dev, PNP_IDX_IO0, 0x2e8);
164 pnp_set_irq(dev, PNP_IDX_IRQ0, 10);
165 pnp_set_enable(dev, 1);
166
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600167 dev = PNP_DEV(0x4e, W83627THG_FDC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000168 pnp_set_logical_device(dev);
169 pnp_set_enable(dev, 0);
170
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600171 dev = PNP_DEV(0x4e, W83627THG_PP);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000172 pnp_set_logical_device(dev);
173 pnp_set_enable(dev, 0);
174
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600175 dev = PNP_DEV(0x4e, W83627THG_KBC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000176 pnp_set_logical_device(dev);
177 pnp_set_enable(dev, 0);
178 pnp_set_iobase(dev, PNP_IDX_IO0, 0x00);
179 pnp_set_iobase(dev, PNP_IDX_IO1, 0x00);
180
Edward O'Callaghan2c55b702014-05-13 23:29:22 +1000181 pnp_exit_func_mode(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000182}
183
184static void rcba_config(void)
185{
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000186 u32 reg32;
187
Stefan Reinauer36a22682008-10-29 04:52:57 +0000188 /* Set up virtual channel 0 */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000189
190 /* Device 1f interrupt pin register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200191 RCBA32(D31IP) = 0x00042210;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000192 /* Device 1d interrupt pin register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200193 RCBA32(D28IP) = 0x00214321;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000194
195 /* dev irq route register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200196 RCBA16(D31IR) = 0x0132;
197 RCBA16(D30IR) = 0x3241;
198 RCBA16(D29IR) = 0x0237;
199 RCBA16(D28IR) = 0x3210;
200 RCBA16(D27IR) = 0x3210;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000201
202 /* Enable IOAPIC */
Arthur Heymansb451df22017-08-15 20:59:09 +0200203 RCBA8(OIC) = 0x03;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000204
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000205 /* Now, this is a bit ugly. As per PCI specification, function 0 of a
206 * device always has to be implemented. So disabling ethernet port 1
207 * would essentially disable all three ethernet ports of the mainboard.
208 * It's possible to rename the ports to achieve compatibility to the
209 * PCI spec but this will confuse all (static!) tables containing
Stefan Reinauer14e22772010-04-27 06:56:47 +0000210 * interrupt routing information.
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000211 * To avoid this, we enable (unused) port 6 and swap it with port 1
212 * in the case that ethernet port 1 is disabled. Since no devices
213 * are connected to that port, we don't have to worry about interrupt
214 * routing.
215 */
216 int port_shuffle = 0;
217
Stefan Reinauer36a22682008-10-29 04:52:57 +0000218 /* Disable unused devices */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000219 reg32 = FD_ACMOD|FD_ACAUD|FD_PATA;
220 reg32 |= FD_PCIE6|FD_PCIE5|FD_PCIE4;
221
Patrick Georgib2517532011-05-10 21:53:13 +0000222 if (read_option(ethernet1, 0) != 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000223 printk(BIOS_DEBUG, "Disabling ethernet adapter 1.\n");
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000224 reg32 |= FD_PCIE1;
225 }
Patrick Georgib2517532011-05-10 21:53:13 +0000226 if (read_option(ethernet2, 0) != 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000227 printk(BIOS_DEBUG, "Disabling ethernet adapter 2.\n");
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000228 reg32 |= FD_PCIE2;
229 } else {
230 if (reg32 & FD_PCIE1)
231 port_shuffle = 1;
232 }
Patrick Georgib2517532011-05-10 21:53:13 +0000233 if (read_option(ethernet3, 0) != 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000234 printk(BIOS_DEBUG, "Disabling ethernet adapter 3.\n");
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000235 reg32 |= FD_PCIE3;
236 } else {
237 if (reg32 & FD_PCIE1)
238 port_shuffle = 1;
239 }
240
241 if (port_shuffle) {
242 /* Enable PCIE6 again */
243 reg32 &= ~FD_PCIE6;
244 /* Swap PCIE6 and PCIE1 */
245 RCBA32(RPFN) = 0x00043215;
246 }
247
248 reg32 |= 1;
249
Arthur Heymansb451df22017-08-15 20:59:09 +0200250 RCBA32(FD) = reg32;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000251
252 /* Enable PCIe Root Port Clock Gate */
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200253
Stefan Reinauer36a22682008-10-29 04:52:57 +0000254}
255
256static void early_ich7_init(void)
257{
258 uint8_t reg8;
259 uint32_t reg32;
260
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200261 /* program secondary mlt XXX byte? */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000262 pci_write_config8(PCI_DEV(0, 0x1e, 0), 0x1b, 0x20);
263
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200264 /* reset rtc power status */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000265 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa4);
266 reg8 &= ~(1 << 2);
267 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xa4, reg8);
268
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200269 /* usb transient disconnect */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000270 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xad);
271 reg8 |= (3 << 0);
272 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xad, reg8);
273
274 reg32 = pci_read_config32(PCI_DEV(0, 0x1d, 7), 0xfc);
275 reg32 |= (1 << 29) | (1 << 17);
276 pci_write_config32(PCI_DEV(0, 0x1d, 7), 0xfc, reg32);
277
278 reg32 = pci_read_config32(PCI_DEV(0, 0x1d, 7), 0xdc);
279 reg32 |= (1 << 31) | (1 << 27);
280 pci_write_config32(PCI_DEV(0, 0x1d, 7), 0xdc, reg32);
281
282 RCBA32(0x0088) = 0x0011d000;
283 RCBA16(0x01fc) = 0x060f;
284 RCBA32(0x01f4) = 0x86000040;
285 RCBA32(0x0214) = 0x10030549;
286 RCBA32(0x0218) = 0x00020504;
287 RCBA8(0x0220) = 0xc5;
Arthur Heymansb451df22017-08-15 20:59:09 +0200288 reg32 = RCBA32(GCS);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000289 reg32 |= (1 << 6);
Arthur Heymansb451df22017-08-15 20:59:09 +0200290 RCBA32(GCS) = reg32;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000291 reg32 = RCBA32(0x3430);
292 reg32 &= ~(3 << 0);
293 reg32 |= (1 << 0);
294 RCBA32(0x3430) = reg32;
Arthur Heymansb451df22017-08-15 20:59:09 +0200295 RCBA32(FD) |= (1 << 0);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000296 RCBA16(0x0200) = 0x2008;
297 RCBA8(0x2027) = 0x0d;
298 RCBA16(0x3e08) |= (1 << 7);
299 RCBA16(0x3e48) |= (1 << 7);
300 RCBA32(0x3e0e) |= (1 << 7);
301 RCBA32(0x3e4e) |= (1 << 7);
302
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200303 /* next step only on ich7m b0 and later: */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000304 reg32 = RCBA32(0x2034);
305 reg32 &= ~(0x0f << 16);
306 reg32 |= (5 << 16);
307 RCBA32(0x2034) = reg32;
308}
309
Kyösti Mälkki15fa9922016-06-17 10:00:28 +0300310void mainboard_romstage_entry(unsigned long bist)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000311{
Vladimir Serbinenko55601882014-10-15 20:17:51 +0200312 int s3resume = 0;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000313
Paul Menzel6c20b652016-12-29 22:54:02 +0100314
315 timestamp_init(get_initial_timestamp());
316 timestamp_add_now(TS_START_ROMSTAGE);
317
Uwe Hermann7b997052010-11-21 22:47:22 +0000318 if (bist == 0)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000319 enable_lapic();
Stefan Reinauer36a22682008-10-29 04:52:57 +0000320
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000321 /* Force PCIRST# */
322 pci_write_config16(PCI_DEV(0, 0x1e, 0), BCTRL, SBR);
Stefan Reinauerbc8613e2010-08-25 18:35:42 +0000323 udelay(200 * 1000);
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000324 pci_write_config16(PCI_DEV(0, 0x1e, 0), BCTRL, 0);
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000325
Stefan Reinauerbc8613e2010-08-25 18:35:42 +0000326 ich7_enable_lpc();
Stefan Reinauer36a22682008-10-29 04:52:57 +0000327 early_superio_config_w83627thg();
328
329 /* Set up the console */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000330 console_init();
331
332 /* Halt if there was a built in self test failure */
333 report_bist_failure(bist);
334
335 if (MCHBAR16(SSKPD) == 0xCAFE) {
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000336 printk(BIOS_DEBUG, "soft reset detected, rebooting properly\n");
337 outb(0x6, 0xcf9);
Patrick Georgi546953c2014-11-29 10:38:17 +0100338 halt();
Stefan Reinauer36a22682008-10-29 04:52:57 +0000339 }
340
341 /* Perform some early chipset initialization required
342 * before RAM initialization can work
343 */
344 i945_early_initialization();
345
Vladimir Serbinenko55601882014-10-15 20:17:51 +0200346 s3resume = southbridge_detect_s3_resume();
Stefan Reinauera5fdadf2009-07-21 21:58:20 +0000347
Stefan Reinauer36a22682008-10-29 04:52:57 +0000348 /* Enable SPD ROMs and DDR-II DRAM */
349 enable_smbus();
Stefan Reinauer14e22772010-04-27 06:56:47 +0000350
Stefan Reinauer08670622009-06-30 15:17:49 +0000351#if CONFIG_DEFAULT_CONSOLE_LOGLEVEL > 8
Stefan Reinauer36a22682008-10-29 04:52:57 +0000352 dump_spd_registers();
353#endif
354
Paul Menzel6c20b652016-12-29 22:54:02 +0100355 timestamp_add_now(TS_BEFORE_INITRAM);
Vladimir Serbinenko55601882014-10-15 20:17:51 +0200356 sdram_initialize(s3resume ? 2 : 0, NULL);
Paul Menzel6c20b652016-12-29 22:54:02 +0100357 timestamp_add_now(TS_AFTER_INITRAM);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000358
359 /* Perform some initialization that must run before stage2 */
360 early_ich7_init();
361
Stefan Reinauer14e22772010-04-27 06:56:47 +0000362 /* This should probably go away. Until now it is required
363 * and mainboard specific
Stefan Reinauer36a22682008-10-29 04:52:57 +0000364 */
365 rcba_config();
366
367 /* Chipset Errata! */
368 fixup_i945_errata();
369
370 /* Initialize the internal PCIe links before we go into stage2 */
Vladimir Serbinenko55601882014-10-15 20:17:51 +0200371 i945_late_initialization(s3resume);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000372}