blob: 5e7a15958a11f7326f22974301376a81e1632664 [file] [log] [blame]
Kyösti Mälkki91162702011-11-03 15:22:01 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 Kyösti Mälkki <kyosti.malkki@gmail.com>
5 *
6 * 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.
9 *
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.
Kyösti Mälkki91162702011-11-03 15:22:01 +020014 */
15
16#include <stdint.h>
17#include <device/pci_def.h>
18#include <arch/io.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020019#include <arch/cpu.h>
20#include <stdlib.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020021#include <console/console.h>
Kyösti Mälkki3aff1a32012-04-11 12:19:03 +030022#include <cpu/x86/bist.h>
Kyösti Mälkki408d3922016-06-17 10:43:48 +030023#include <cpu/intel/romstage.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020024
Edward O'Callaghan77757c22015-01-04 21:33:39 +110025#include <southbridge/intel/i82801dx/i82801dx.h>
26#include <northbridge/intel/e7505/raminit.h>
Kyösti Mälkki93b4ed92012-04-18 21:13:33 +030027
28#include <device/pnp_def.h>
Edward O'Callaghanc3e77fc2015-01-04 16:24:14 +110029#include <superio/smsc/lpc47m10x/lpc47m10x.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020030
31#define SERIAL_DEV PNP_DEV(0x2e, LPC47M10X2_SP1)
32
Kyösti Mälkki93b4ed92012-04-18 21:13:33 +030033int spd_read_byte(unsigned device, unsigned address)
Kyösti Mälkki91162702011-11-03 15:22:01 +020034{
35 return smbus_read_byte(device, address);
36}
37
Kyösti Mälkki408d3922016-06-17 10:43:48 +030038void mainboard_romstage_entry(unsigned long bist)
Kyösti Mälkki91162702011-11-03 15:22:01 +020039{
40 static const struct mem_controller memctrl[] = {
41 {
42 .d0 = PCI_DEV(0, 0, 0),
43 .d0f1 = PCI_DEV(0, 0, 1),
44 .channel0 = { 0x50, 0x52, 0, 0 },
45 .channel1 = { 0x51, 0x53, 0, 0 },
46 },
47 };
48
Kyösti Mälkki91162702011-11-03 15:22:01 +020049 // Get the serial port running and print a welcome banner
50 lpc47m10x_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
51 console_init();
52
53 // Halt if there was a built in self test failure
54 report_bist_failure(bist);
55
56 // If this is a warm boot, some initialization can be skipped
Kyösti Mälkki93b4ed92012-04-18 21:13:33 +030057 if (!e7505_mch_is_ready()) {
Kyösti Mälkki91162702011-11-03 15:22:01 +020058 enable_smbus();
Kyösti Mälkki97c064f2012-04-18 20:33:35 +030059
60 /* The real MCH initialisation. */
61 e7505_mch_init(memctrl);
62
63 /*
64 * ECC scrub invalidates cache, so all stack in CAR
65 * is lost. Only return addresses from main() and
66 * scrub_ecc() are recovered to stack via xmm0-xmm3.
67 */
68#if CONFIG_HW_SCRUBBER
Kyösti Mälkki48713a12014-04-15 18:19:48 +030069#if !CONFIG_USBDEBUG_IN_ROMSTAGE
Kyösti Mälkki97c064f2012-04-18 20:33:35 +030070 unsigned long ret_addr = (unsigned long)((unsigned long*)&bist - 1);
71 e7505_mch_scrub_ecc(ret_addr);
72#endif
Kyösti Mälkkib7d7cfb2013-06-06 10:39:48 +030073#endif
Kyösti Mälkki97c064f2012-04-18 20:33:35 +030074
75 /* Hook for post ECC scrub settings and debug. */
76 e7505_mch_done(memctrl);
Kyösti Mälkki91162702011-11-03 15:22:01 +020077 }
78
Kyösti Mälkki97c064f2012-04-18 20:33:35 +030079 printk(BIOS_DEBUG, "SDRAM is up.\n");
Kyösti Mälkki91162702011-11-03 15:22:01 +020080}