blob: 925c93efe8c8fbd8266ace18323f40753bcd1f59 [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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Uwe Hermann2bb4acf2010-03-01 17:19:55 +000017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Stefan Reinauer36a22682008-10-29 04:52:57 +000018 */
19
Myles Watson1d6d45e2009-11-06 17:02:51 +000020// __PRE_RAM__ means: use "unsigned" for device, not a struct.
Stefan Reinauer5e328232010-03-29 19:19:16 +000021
Stefan Reinauer36a22682008-10-29 04:52:57 +000022#include <stdint.h>
Patrick Georgi12aba822009-04-30 07:07:22 +000023#include <string.h>
Patrick Georgid0835952010-10-05 09:07:10 +000024#include <lib.h>
Stefan Reinauer36a22682008-10-29 04:52:57 +000025#include <arch/io.h>
26#include <arch/romcc_io.h>
27#include <device/pci_def.h>
28#include <device/pnp_def.h>
29#include <cpu/x86/lapic.h>
Patrick Georgi5692c572010-10-05 13:40:31 +000030#include <usbdebug.h>
Stefan Reinauer36a22682008-10-29 04:52:57 +000031#include "superio/winbond/w83627thg/w83627thg.h"
Edwin Beasanteb50c7d2010-07-06 21:05:04 +000032#include <pc80/mc146818rtc.h>
Stefan Reinauer10ec0fe2010-09-25 10:40:47 +000033#include "option_table.h"
Stefan Reinauerde3206a2010-02-22 06:09:43 +000034#include <console/console.h>
Stefan Reinauer36a22682008-10-29 04:52:57 +000035#include <cpu/x86/bist.h>
stepan8301d832010-12-08 07:07:33 +000036#include "superio/winbond/w83627thg/early_serial.c"
Patrick Georgid0835952010-10-05 09:07:10 +000037#include "northbridge/intel/i945/i945.h"
38#include "northbridge/intel/i945/raminit.h"
Stefan Reinauera5fdadf2009-07-21 21:58:20 +000039#include "southbridge/intel/i82801gx/i82801gx.h"
Patrick Georgid0835952010-10-05 09:07:10 +000040
Uwe Hermann57b2ff82010-11-21 17:29:59 +000041#define SERIAL_DEV PNP_DEV(0x2e, W83627THG_SP1)
42
Patrick Georgid0835952010-10-05 09:07:10 +000043void setup_ich7_gpios(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000044{
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000045 printk(BIOS_DEBUG, " GPIOS...");
Stefan Reinauer36a22682008-10-29 04:52:57 +000046 /* General Registers */
47 outl(0x1f1ff7c0, DEFAULT_GPIOBASE + 0x00); /* GPIO_USE_SEL */
48 outl(0xe0e8efc3, DEFAULT_GPIOBASE + 0x04); /* GP_IO_SEL */
49 outl(0xebffeeff, DEFAULT_GPIOBASE + 0x0c); /* GP_LVL */
50 /* Output Control Registers */
51 outl(0x00000000, DEFAULT_GPIOBASE + 0x18); /* GPO_BLINK */
52 /* Input Control Registers */
53 outl(0x00002180, DEFAULT_GPIOBASE + 0x2c); /* GPI_INV */
Stefan Reinauere1025d02009-03-11 15:20:36 +000054 outl(0x000100ff, DEFAULT_GPIOBASE + 0x30); /* GPIO_USE_SEL2 */
Stefan Reinauer36a22682008-10-29 04:52:57 +000055 outl(0x00000030, DEFAULT_GPIOBASE + 0x34); /* GP_IO_SEL2 */
56 outl(0x00010035, DEFAULT_GPIOBASE + 0x38); /* GP_LVL */
57}
58
Stefan Reinauer36a22682008-10-29 04:52:57 +000059static void ich7_enable_lpc(void)
60{
Patrick Georgia4700192011-01-27 07:39:38 +000061 int lpt_en = 0;
62 if (read_option(CMOS_VSTART_lpt, CMOS_VLEN_lpt, 0) != 0) {
63 lpt_en = 1<<2; // enable LPT
64 }
Stefan Reinauer36a22682008-10-29 04:52:57 +000065 // Enable Serial IRQ
66 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x64, 0xd0);
67 // Set COM1/COM2 decode range
68 pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x80, 0x0010);
69 // Enable COM1/COM2/KBD/SuperIO1+2
Patrick Georgia4700192011-01-27 07:39:38 +000070 pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x340b | lpt_en);
Stefan Reinauer36a22682008-10-29 04:52:57 +000071 // Enable HWM at 0xa00
Stefan Reinauere1025d02009-03-11 15:20:36 +000072 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x84, 0x00fc0a01);
Stefan Reinauer36a22682008-10-29 04:52:57 +000073 // COM3 decode
74 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x88, 0x000403e9);
75 // COM4 decode
76 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x8c, 0x000402e9);
Stefan Reinauer14e22772010-04-27 06:56:47 +000077 // io 0x300 decode
Stefan Reinauer36a22682008-10-29 04:52:57 +000078 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x90, 0x00000301);
79}
80
Stefan Reinauer36a22682008-10-29 04:52:57 +000081/* This box has two superios, so enabling serial becomes slightly excessive.
82 * We disable a lot of stuff to make sure that there are no conflicts between
83 * the two. Also set up the GPIOs from the beginning. This is the "no schematic
84 * but safe anyways" method.
85 */
86static void early_superio_config_w83627thg(void)
87{
88 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000089
Stefan Reinauer36a22682008-10-29 04:52:57 +000090 dev=PNP_DEV(0x2e, W83627THG_SP1);
91 pnp_enter_ext_func_mode(dev);
92
Stefan Reinaueraca6ec62009-10-26 17:12:21 +000093 pnp_write_config(dev, 0x24, 0xc6); // PNPCSV
94
95 pnp_write_config(dev, 0x29, 0x43); // GPIO settings
96 pnp_write_config(dev, 0x2a, 0x40); // GPIO settings
97
98 dev=PNP_DEV(0x2e, W83627THG_SP1);
Stefan Reinauer36a22682008-10-29 04:52:57 +000099 pnp_set_logical_device(dev);
100 pnp_set_enable(dev, 0);
101 pnp_set_iobase(dev, PNP_IDX_IO0, 0x3f8);
102 pnp_set_irq(dev, PNP_IDX_IRQ0, 4);
103 pnp_set_enable(dev, 1);
104
105 dev=PNP_DEV(0x2e, W83627THG_SP2);
106 pnp_set_logical_device(dev);
107 pnp_set_enable(dev, 0);
108 pnp_set_iobase(dev, PNP_IDX_IO0, 0x2f8);
109 pnp_set_irq(dev, PNP_IDX_IRQ0, 3);
110 // pnp_write_config(dev, 0xf1, 4); // IRMODE0
111 pnp_set_enable(dev, 1);
112
113 dev=PNP_DEV(0x2e, W83627THG_KBC);
114 pnp_set_logical_device(dev);
115 pnp_set_enable(dev, 0);
116 pnp_set_iobase(dev, PNP_IDX_IO0, 0x60);
117 pnp_set_iobase(dev, PNP_IDX_IO1, 0x64);
118 // pnp_write_config(dev, 0xf0, 0x82);
119 pnp_set_enable(dev, 1);
120
121 dev=PNP_DEV(0x2e, W83627THG_GAME_MIDI_GPIO1);
122 pnp_set_logical_device(dev);
123 pnp_set_enable(dev, 0);
124 pnp_write_config(dev, 0xf5, 0xff); // invert all GPIOs
125 pnp_set_enable(dev, 1);
126
127 dev=PNP_DEV(0x2e, W83627THG_GPIO2);
128 pnp_set_logical_device(dev);
129 pnp_set_enable(dev, 1); // Just enable it
130
131 dev=PNP_DEV(0x2e, W83627THG_GPIO3);
132 pnp_set_logical_device(dev);
133 pnp_set_enable(dev, 0);
134 pnp_write_config(dev, 0xf0, 0xfb); // GPIO bit 2 is output
135 pnp_write_config(dev, 0xf1, 0x00); // GPIO bit 2 is 0
136 pnp_write_config(dev, 0x30, 0x03); // Enable GPIO3+4. pnp_set_enable is not sufficient
137
138 dev=PNP_DEV(0x2e, W83627THG_FDC);
139 pnp_set_logical_device(dev);
140 pnp_set_enable(dev, 0);
141
142 dev=PNP_DEV(0x2e, W83627THG_PP);
143 pnp_set_logical_device(dev);
144 pnp_set_enable(dev, 0);
145
Stefan Reinauer54309d62009-01-20 22:53:10 +0000146 /* Enable HWM */
147 dev=PNP_DEV(0x2e, W83627THG_HWM);
148 pnp_set_logical_device(dev);
149 pnp_set_enable(dev, 0);
150 pnp_set_iobase(dev, PNP_IDX_IO0, 0xa00);
151 pnp_set_enable(dev, 1);
152
Stefan Reinauer36a22682008-10-29 04:52:57 +0000153 pnp_exit_ext_func_mode(dev);
154
155 dev=PNP_DEV(0x4e, W83627THG_SP1);
156 pnp_enter_ext_func_mode(dev);
157
158 pnp_set_logical_device(dev); // Set COM3 to sane non-conflicting values
159 pnp_set_enable(dev, 0);
160 pnp_set_iobase(dev, PNP_IDX_IO0, 0x3e8);
161 pnp_set_irq(dev, PNP_IDX_IRQ0, 11);
162 pnp_set_enable(dev, 1);
163
Stefan Reinauer14e22772010-04-27 06:56:47 +0000164 dev=PNP_DEV(0x4e, W83627THG_SP2);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000165 pnp_set_logical_device(dev); // Set COM4 to sane non-conflicting values
166 pnp_set_enable(dev, 0);
167 pnp_set_iobase(dev, PNP_IDX_IO0, 0x2e8);
168 pnp_set_irq(dev, PNP_IDX_IRQ0, 10);
169 pnp_set_enable(dev, 1);
170
171 dev=PNP_DEV(0x4e, W83627THG_FDC);
172 pnp_set_logical_device(dev);
173 pnp_set_enable(dev, 0);
174
175 dev=PNP_DEV(0x4e, W83627THG_PP);
176 pnp_set_logical_device(dev);
177 pnp_set_enable(dev, 0);
178
179 dev=PNP_DEV(0x4e, W83627THG_KBC);
180 pnp_set_logical_device(dev);
181 pnp_set_enable(dev, 0);
182 pnp_set_iobase(dev, PNP_IDX_IO0, 0x00);
183 pnp_set_iobase(dev, PNP_IDX_IO1, 0x00);
184
185 pnp_exit_ext_func_mode(dev);
186}
187
188static void rcba_config(void)
189{
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000190 u32 reg32;
191
Stefan Reinauer36a22682008-10-29 04:52:57 +0000192 /* Set up virtual channel 0 */
193 //RCBA32(0x0014) = 0x80000001;
194 //RCBA32(0x001c) = 0x03128010;
195
196 /* Device 1f interrupt pin register */
197 RCBA32(0x3100) = 0x00042210;
198 /* Device 1d interrupt pin register */
199 RCBA32(0x310c) = 0x00214321;
200
201 /* dev irq route register */
202 RCBA16(0x3140) = 0x0132;
203 RCBA16(0x3142) = 0x3241;
204 RCBA16(0x3144) = 0x0237;
205 RCBA16(0x3146) = 0x3210;
206 RCBA16(0x3148) = 0x3210;
207
208 /* Enable IOAPIC */
209 RCBA8(0x31ff) = 0x03;
210
211 /* Enable upper 128bytes of CMOS */
212 RCBA32(0x3400) = (1 << 2);
213
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000214 /* Now, this is a bit ugly. As per PCI specification, function 0 of a
215 * device always has to be implemented. So disabling ethernet port 1
216 * would essentially disable all three ethernet ports of the mainboard.
217 * It's possible to rename the ports to achieve compatibility to the
218 * PCI spec but this will confuse all (static!) tables containing
Stefan Reinauer14e22772010-04-27 06:56:47 +0000219 * interrupt routing information.
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000220 * To avoid this, we enable (unused) port 6 and swap it with port 1
221 * in the case that ethernet port 1 is disabled. Since no devices
222 * are connected to that port, we don't have to worry about interrupt
223 * routing.
224 */
225 int port_shuffle = 0;
226
Stefan Reinauer36a22682008-10-29 04:52:57 +0000227 /* Disable unused devices */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000228 reg32 = FD_ACMOD|FD_ACAUD|FD_PATA;
229 reg32 |= FD_PCIE6|FD_PCIE5|FD_PCIE4;
230
231 if (read_option(CMOS_VSTART_ethernet1, CMOS_VLEN_ethernet1, 0) != 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000232 printk(BIOS_DEBUG, "Disabling ethernet adapter 1.\n");
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000233 reg32 |= FD_PCIE1;
234 }
235 if (read_option(CMOS_VSTART_ethernet2, CMOS_VLEN_ethernet2, 0) != 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000236 printk(BIOS_DEBUG, "Disabling ethernet adapter 2.\n");
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000237 reg32 |= FD_PCIE2;
238 } else {
239 if (reg32 & FD_PCIE1)
240 port_shuffle = 1;
241 }
242 if (read_option(CMOS_VSTART_ethernet3, CMOS_VLEN_ethernet3, 0) != 0) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000243 printk(BIOS_DEBUG, "Disabling ethernet adapter 3.\n");
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000244 reg32 |= FD_PCIE3;
245 } else {
246 if (reg32 & FD_PCIE1)
247 port_shuffle = 1;
248 }
249
250 if (port_shuffle) {
251 /* Enable PCIE6 again */
252 reg32 &= ~FD_PCIE6;
253 /* Swap PCIE6 and PCIE1 */
254 RCBA32(RPFN) = 0x00043215;
255 }
256
257 reg32 |= 1;
258
259 RCBA32(0x3418) = reg32;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000260
261 /* Enable PCIe Root Port Clock Gate */
262 // RCBA32(0x341c) = 0x00000001;
263}
264
265static void early_ich7_init(void)
266{
267 uint8_t reg8;
268 uint32_t reg32;
269
270 // program secondary mlt XXX byte?
271 pci_write_config8(PCI_DEV(0, 0x1e, 0), 0x1b, 0x20);
272
273 // reset rtc power status
274 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa4);
275 reg8 &= ~(1 << 2);
276 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xa4, reg8);
277
278 // usb transient disconnect
279 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xad);
280 reg8 |= (3 << 0);
281 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xad, reg8);
282
283 reg32 = pci_read_config32(PCI_DEV(0, 0x1d, 7), 0xfc);
284 reg32 |= (1 << 29) | (1 << 17);
285 pci_write_config32(PCI_DEV(0, 0x1d, 7), 0xfc, reg32);
286
287 reg32 = pci_read_config32(PCI_DEV(0, 0x1d, 7), 0xdc);
288 reg32 |= (1 << 31) | (1 << 27);
289 pci_write_config32(PCI_DEV(0, 0x1d, 7), 0xdc, reg32);
290
291 RCBA32(0x0088) = 0x0011d000;
292 RCBA16(0x01fc) = 0x060f;
293 RCBA32(0x01f4) = 0x86000040;
294 RCBA32(0x0214) = 0x10030549;
295 RCBA32(0x0218) = 0x00020504;
296 RCBA8(0x0220) = 0xc5;
297 reg32 = RCBA32(0x3410);
298 reg32 |= (1 << 6);
299 RCBA32(0x3410) = reg32;
300 reg32 = RCBA32(0x3430);
301 reg32 &= ~(3 << 0);
302 reg32 |= (1 << 0);
303 RCBA32(0x3430) = reg32;
304 RCBA32(0x3418) |= (1 << 0);
305 RCBA16(0x0200) = 0x2008;
306 RCBA8(0x2027) = 0x0d;
307 RCBA16(0x3e08) |= (1 << 7);
308 RCBA16(0x3e48) |= (1 << 7);
309 RCBA32(0x3e0e) |= (1 << 7);
310 RCBA32(0x3e4e) |= (1 << 7);
311
312 // next step only on ich7m b0 and later:
313 reg32 = RCBA32(0x2034);
314 reg32 &= ~(0x0f << 16);
315 reg32 |= (5 << 16);
316 RCBA32(0x2034) = reg32;
317}
318
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000319#include <cbmem.h>
320
Stefan Reinauer3e1f5242010-04-12 23:04:29 +0000321void main(unsigned long bist)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000322{
Stefan Reinauera5fdadf2009-07-21 21:58:20 +0000323 u32 reg32;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000324 int boot_mode = 0;
325
Uwe Hermann7b997052010-11-21 22:47:22 +0000326 if (bist == 0)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000327 enable_lapic();
Stefan Reinauer36a22682008-10-29 04:52:57 +0000328
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000329 /* Force PCIRST# */
330 pci_write_config16(PCI_DEV(0, 0x1e, 0), BCTRL, SBR);
Stefan Reinauerbc8613e2010-08-25 18:35:42 +0000331 udelay(200 * 1000);
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000332 pci_write_config16(PCI_DEV(0, 0x1e, 0), BCTRL, 0);
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000333
Stefan Reinauerbc8613e2010-08-25 18:35:42 +0000334 ich7_enable_lpc();
Stefan Reinauer36a22682008-10-29 04:52:57 +0000335 early_superio_config_w83627thg();
336
337 /* Set up the console */
338 uart_init();
Stefan Reinauera5fdadf2009-07-21 21:58:20 +0000339
Stefan Reinauer7e00a442010-05-25 17:09:05 +0000340#if CONFIG_USBDEBUG
Uwe Hermann370d9792010-09-25 14:23:31 +0000341 i82801gx_enable_usbdebug(1);
Stefan Reinauer75a05dc2010-05-25 16:35:51 +0000342 early_usbdebug_init();
Stefan Reinauera5fdadf2009-07-21 21:58:20 +0000343#endif
344
Stefan Reinauer36a22682008-10-29 04:52:57 +0000345 console_init();
346
347 /* Halt if there was a built in self test failure */
348 report_bist_failure(bist);
349
350 if (MCHBAR16(SSKPD) == 0xCAFE) {
Stefan Reinauerbf264e92010-05-14 19:09:20 +0000351 printk(BIOS_DEBUG, "soft reset detected, rebooting properly\n");
352 outb(0x6, 0xcf9);
353 while (1) asm("hlt");
Stefan Reinauer36a22682008-10-29 04:52:57 +0000354 }
355
356 /* Perform some early chipset initialization required
357 * before RAM initialization can work
358 */
359 i945_early_initialization();
360
Stefan Reinauera5fdadf2009-07-21 21:58:20 +0000361 /* Read PM1_CNT */
362 reg32 = inl(DEFAULT_PMBASE + 0x04);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000363 printk(BIOS_DEBUG, "PM1_CNT: %08x\n", reg32);
Stefan Reinauera5fdadf2009-07-21 21:58:20 +0000364 if (((reg32 >> 10) & 7) == 5) {
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000365#if CONFIG_HAVE_ACPI_RESUME
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000366 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
Stefan Reinauera5fdadf2009-07-21 21:58:20 +0000367 boot_mode = 2;
368 /* Clear SLP_TYPE. This will break stage2 but
369 * we care for that when we get there.
370 */
371 outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04);
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000372
Stefan Reinauera5fdadf2009-07-21 21:58:20 +0000373#else
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000374 printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n");
Stefan Reinauera5fdadf2009-07-21 21:58:20 +0000375#endif
376 }
377
Stefan Reinauer36a22682008-10-29 04:52:57 +0000378 /* Enable SPD ROMs and DDR-II DRAM */
379 enable_smbus();
Stefan Reinauer14e22772010-04-27 06:56:47 +0000380
Stefan Reinauer08670622009-06-30 15:17:49 +0000381#if CONFIG_DEFAULT_CONSOLE_LOGLEVEL > 8
Stefan Reinauer36a22682008-10-29 04:52:57 +0000382 dump_spd_registers();
383#endif
384
385 sdram_initialize(boot_mode);
386
387 /* Perform some initialization that must run before stage2 */
388 early_ich7_init();
389
Stefan Reinauer14e22772010-04-27 06:56:47 +0000390 /* This should probably go away. Until now it is required
391 * and mainboard specific
Stefan Reinauer36a22682008-10-29 04:52:57 +0000392 */
393 rcba_config();
394
395 /* Chipset Errata! */
396 fixup_i945_errata();
397
398 /* Initialize the internal PCIe links before we go into stage2 */
399 i945_late_initialization();
400
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000401#if !CONFIG_HAVE_ACPI_RESUME
Stefan Reinauer08670622009-06-30 15:17:49 +0000402#if CONFIG_DEFAULT_CONSOLE_LOGLEVEL > 8
Uwe Hermann01ce6012010-03-05 10:03:50 +0000403#if CONFIG_DEBUG_RAM_SETUP
Stefan Reinauer36a22682008-10-29 04:52:57 +0000404 sdram_dump_mchbar_registers();
405#endif
406
407 {
408 /* This will not work if TSEG is in place! */
409 u32 tom = pci_read_config32(PCI_DEV(0,2,0), 0x5c);
410
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000411 printk(BIOS_DEBUG, "TOM: 0x%08x\n", tom);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000412 ram_check(0x00000000, 0x000a0000);
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000413 //ram_check(0x00100000, tom);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000414 }
415#endif
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000416#endif
417
Stefan Reinauere0d607a2010-03-28 21:31:30 +0000418 quick_ram_check();
419
Stefan Reinauer36a22682008-10-29 04:52:57 +0000420 MCHBAR16(SSKPD) = 0xCAFE;
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000421
422#if CONFIG_HAVE_ACPI_RESUME
423 /* Start address of high memory tables */
424 unsigned long high_ram_base = get_top_of_ram() - HIGH_MEMORY_SIZE;
425
426 /* If there is no high memory area, we didn't boot before, so
427 * this is not a resume. In that case we just create the cbmem toc.
428 */
429 if ((boot_mode == 2) && cbmem_reinit((u64)high_ram_base)) {
430 void *resume_backup_memory = cbmem_find(CBMEM_ID_RESUME);
431
432 /* copy 1MB - 64K to high tables ram_base to prevent memory corruption
433 * through stage 2. We could keep stuff like stack and heap in high tables
434 * memory completely, but that's a wonderful clean up task for another
435 * day.
436 */
Stefan Reinauer14e22772010-04-27 06:56:47 +0000437 if (resume_backup_memory)
Stefan Reinauerde3206a2010-02-22 06:09:43 +0000438 memcpy(resume_backup_memory, (void *)CONFIG_RAMBASE, HIGH_MEMORY_SAVE);
Stefan Reinaueraca6ec62009-10-26 17:12:21 +0000439
440 /* Magic for S3 resume */
441 pci_write_config32(PCI_DEV(0, 0x00, 0), SKPAD, 0xcafed00d);
442 }
443#endif
Stefan Reinauer36a22682008-10-29 04:52:57 +0000444}