blob: 1b3e785017110a4151c054f61b05380c1296f456 [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.
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
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <stdint.h>
21#include <device/pci_def.h>
22#include <arch/io.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020023#include <arch/romcc_io.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020024#include <arch/cpu.h>
25#include <stdlib.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020026#include <console/console.h>
Kyösti Mälkki3aff1a32012-04-11 12:19:03 +030027#include <cpu/x86/bist.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020028
29#include "southbridge/intel/i82801dx/i82801dx.h"
30#include "southbridge/intel/i82801dx/early_smbus.c"
31#include "southbridge/intel/i82801dx/reset.c"
32#include "northbridge/intel/e7505/raminit.h"
Kyösti Mälkki93b4ed92012-04-18 21:13:33 +030033
34#include <device/pnp_def.h>
Kyösti Mälkki91162702011-11-03 15:22:01 +020035#include "superio/smsc/lpc47m10x/early_serial.c"
36
Kyösti Mälkki91162702011-11-03 15:22:01 +020037
38#define SERIAL_DEV PNP_DEV(0x2e, LPC47M10X2_SP1)
39
Kyösti Mälkki93b4ed92012-04-18 21:13:33 +030040int spd_read_byte(unsigned device, unsigned address)
Kyösti Mälkki91162702011-11-03 15:22:01 +020041{
42 return smbus_read_byte(device, address);
43}
44
Kyösti Mälkki3aff1a32012-04-11 12:19:03 +030045void main(unsigned long bist)
Kyösti Mälkki91162702011-11-03 15:22:01 +020046{
47 static const struct mem_controller memctrl[] = {
48 {
49 .d0 = PCI_DEV(0, 0, 0),
50 .d0f1 = PCI_DEV(0, 0, 1),
51 .channel0 = { 0x50, 0x52, 0, 0 },
52 .channel1 = { 0x51, 0x53, 0, 0 },
53 },
54 };
55
Kyösti Mälkki91162702011-11-03 15:22:01 +020056 // Get the serial port running and print a welcome banner
57 lpc47m10x_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
58 console_init();
59
60 // Halt if there was a built in self test failure
61 report_bist_failure(bist);
62
63 // If this is a warm boot, some initialization can be skipped
Kyösti Mälkki93b4ed92012-04-18 21:13:33 +030064 if (!e7505_mch_is_ready()) {
Kyösti Mälkki91162702011-11-03 15:22:01 +020065 enable_smbus();
Kyösti Mälkki97c064f2012-04-18 20:33:35 +030066
67 /* The real MCH initialisation. */
68 e7505_mch_init(memctrl);
69
70 /*
71 * ECC scrub invalidates cache, so all stack in CAR
72 * is lost. Only return addresses from main() and
73 * scrub_ecc() are recovered to stack via xmm0-xmm3.
74 */
75#if CONFIG_HW_SCRUBBER
76 unsigned long ret_addr = (unsigned long)((unsigned long*)&bist - 1);
77 e7505_mch_scrub_ecc(ret_addr);
78#endif
79
80 /* Hook for post ECC scrub settings and debug. */
81 e7505_mch_done(memctrl);
Kyösti Mälkki91162702011-11-03 15:22:01 +020082 }
83
Kyösti Mälkki97c064f2012-04-18 20:33:35 +030084 printk(BIOS_DEBUG, "SDRAM is up.\n");
Kyösti Mälkki91162702011-11-03 15:22:01 +020085}