blob: 6ea1261231b95d6e82b8cd9dbcd7fea8fb7310ab [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älkki717b6e32018-05-17 14:16:03 +030021#include <cbmem.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020022#include <console/console.h>
Kyösti Mälkki3aff1a32012-04-11 12:19:03 +030023#include <cpu/x86/bist.h>
Kyösti Mälkki408d3922016-06-17 10:43:48 +030024#include <cpu/intel/romstage.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020025
Edward O'Callaghan77757c22015-01-04 21:33:39 +110026#include <southbridge/intel/i82801dx/i82801dx.h>
27#include <northbridge/intel/e7505/raminit.h>
Kyösti Mälkki93b4ed92012-04-18 21:13:33 +030028
29#include <device/pnp_def.h>
Edward O'Callaghanc3e77fc2015-01-04 16:24:14 +110030#include <superio/smsc/lpc47m10x/lpc47m10x.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020031
32#define SERIAL_DEV PNP_DEV(0x2e, LPC47M10X2_SP1)
33
Kyösti Mälkki93b4ed92012-04-18 21:13:33 +030034int spd_read_byte(unsigned device, unsigned address)
Kyösti Mälkki91162702011-11-03 15:22:01 +020035{
36 return smbus_read_byte(device, address);
37}
38
Kyösti Mälkki408d3922016-06-17 10:43:48 +030039void mainboard_romstage_entry(unsigned long bist)
Kyösti Mälkki91162702011-11-03 15:22:01 +020040{
41 static const struct mem_controller memctrl[] = {
42 {
43 .d0 = PCI_DEV(0, 0, 0),
44 .d0f1 = PCI_DEV(0, 0, 1),
45 .channel0 = { 0x50, 0x52, 0, 0 },
46 .channel1 = { 0x51, 0x53, 0, 0 },
47 },
48 };
49
Elyes HAOUAS46829862016-10-07 17:35:50 +020050 /* Get the serial port running and print a welcome banner */
Kyösti Mälkki91162702011-11-03 15:22:01 +020051 lpc47m10x_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
52 console_init();
53
Elyes HAOUAS46829862016-10-07 17:35:50 +020054 /* Halt if there was a built in self test failure */
Kyösti Mälkki91162702011-11-03 15:22:01 +020055 report_bist_failure(bist);
56
Elyes HAOUAS46829862016-10-07 17:35:50 +020057 /* If this is a warm boot, some initialization can be skipped */
Kyösti Mälkki93b4ed92012-04-18 21:13:33 +030058 if (!e7505_mch_is_ready()) {
Kyösti Mälkki91162702011-11-03 15:22:01 +020059 enable_smbus();
Kyösti Mälkki97c064f2012-04-18 20:33:35 +030060
61 /* The real MCH initialisation. */
62 e7505_mch_init(memctrl);
63
64 /*
65 * ECC scrub invalidates cache, so all stack in CAR
66 * is lost. Only return addresses from main() and
67 * scrub_ecc() are recovered to stack via xmm0-xmm3.
68 */
Martin Rothf95911a2017-06-24 21:45:13 -060069#if IS_ENABLED(CONFIG_HW_SCRUBBER)
70#if !IS_ENABLED(CONFIG_USBDEBUG_IN_ROMSTAGE)
Kyösti Mälkki97c064f2012-04-18 20:33:35 +030071 unsigned long ret_addr = (unsigned long)((unsigned long*)&bist - 1);
72 e7505_mch_scrub_ecc(ret_addr);
73#endif
Kyösti Mälkkib7d7cfb2013-06-06 10:39:48 +030074#endif
Kyösti Mälkki97c064f2012-04-18 20:33:35 +030075
76 /* Hook for post ECC scrub settings and debug. */
77 e7505_mch_done(memctrl);
Kyösti Mälkki91162702011-11-03 15:22:01 +020078 }
79
Kyösti Mälkki97c064f2012-04-18 20:33:35 +030080 printk(BIOS_DEBUG, "SDRAM is up.\n");
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030081
82 cbmem_recovery(0);
Kyösti Mälkki91162702011-11-03 15:22:01 +020083}