Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008 Arastra, Inc. |
| 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 version 2 as |
| 8 | * published by the Free Software Foundation. |
| 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. |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 16 | #include <stdint.h> |
| 17 | #include <stdlib.h> |
| 18 | #include <device/pci_def.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include <arch/io.h> |
| 21 | #include <device/pnp_def.h> |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 22 | #include <cpu/x86/lapic.h> |
Edwin Beasant | eb50c7d | 2010-07-06 21:05:04 +0000 | [diff] [blame] | 23 | #include <pc80/mc146818rtc.h> |
Patrick Georgi | 12584e2 | 2010-05-08 09:14:51 +0000 | [diff] [blame] | 24 | #include <console/console.h> |
stepan | 836ae29 | 2010-12-08 05:42:47 +0000 | [diff] [blame] | 25 | #include "southbridge/intel/i3100/early_smbus.c" |
| 26 | #include "southbridge/intel/i3100/early_lpc.c" |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 27 | #include <northbridge/intel/i3100/raminit_ep80579.h> |
Edward O'Callaghan | 74834e0 | 2015-01-04 04:17:35 +1100 | [diff] [blame] | 28 | #include <superio/intel/i3100/i3100.h> |
Edward O'Callaghan | 633f6e3 | 2014-11-02 10:17:10 +1100 | [diff] [blame] | 29 | #include "lib/debug.c" // XXX |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 30 | #include <cpu/x86/bist.h> |
Kyösti Mälkki | 07921540d | 2016-06-17 17:22:00 +0300 | [diff] [blame] | 31 | #include <cpu/intel/romstage.h> |
Patrick Georgi | 9bd9a90 | 2010-11-20 10:31:00 +0000 | [diff] [blame] | 32 | #include <spd.h> |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 33 | |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 34 | #define DEVPRES_CONFIG (DEVPRES_D1F0 | DEVPRES_D2F0 | DEVPRES_D3F0 | DEVPRES_D4F0) |
| 35 | |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 36 | static inline int spd_read_byte(u16 device, u8 address) |
| 37 | { |
| 38 | return smbus_read_byte(device, address); |
| 39 | } |
| 40 | |
| 41 | #include "northbridge/intel/i3100/raminit_ep80579.c" |
Stefan Reinauer | c13093b | 2009-09-23 18:51:03 +0000 | [diff] [blame] | 42 | #include "lib/generic_sdram.c" |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 43 | |
Uwe Hermann | d1a1d57 | 2010-11-10 18:22:11 +0000 | [diff] [blame] | 44 | #define SERIAL_DEV PNP_DEV(0x4e, I3100_SP1) |
| 45 | |
Kyösti Mälkki | 07921540d | 2016-06-17 17:22:00 +0300 | [diff] [blame] | 46 | void mainboard_romstage_entry(unsigned long bist) |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 47 | { |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 48 | static const struct mem_controller mch[] = { |
| 49 | { |
| 50 | .node_id = 0, |
| 51 | .f0 = PCI_DEV(0, 0x00, 0), |
Uwe Hermann | 6dc92f0 | 2010-11-21 11:36:03 +0000 | [diff] [blame] | 52 | .channel0 = { DIMM2, DIMM3 }, |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 53 | } |
| 54 | }; |
| 55 | |
| 56 | if (bist == 0) { |
| 57 | /* Skip this if there was a built in self test failure */ |
Uwe Hermann | 7b99705 | 2010-11-21 22:47:22 +0000 | [diff] [blame] | 58 | if (memory_initialized()) |
Stefan Reinauer | 61ed48c | 2014-12-17 13:23:05 -0800 | [diff] [blame] | 59 | return; |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | /* Set up the console */ |
| 63 | i3100_enable_superio(); |
Uwe Hermann | d1a1d57 | 2010-11-10 18:22:11 +0000 | [diff] [blame] | 64 | i3100_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); |
| 65 | i3100_configure_uart_clk(SERIAL_DEV, I3100_UART_CLK_PREDIVIDE_26); |
| 66 | |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 67 | console_init(); |
| 68 | |
| 69 | /* Prevent the TCO timer from rebooting us */ |
| 70 | i3100_halt_tco_timer(); |
| 71 | |
| 72 | /* Halt if there was a built in self test failure */ |
| 73 | report_bist_failure(bist); |
| 74 | |
| 75 | #ifdef TRUXTON_DEBUG |
| 76 | print_pci_devices(); |
| 77 | #endif |
| 78 | enable_smbus(); |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 79 | |
| 80 | sdram_initialize(ARRAY_SIZE(mch), mch); |
| 81 | dump_pci_devices(); |
| 82 | dump_pci_device(PCI_DEV(0, 0x00, 0)); |
| 83 | #ifdef TRUXTON_DEBUG |
| 84 | dump_bar14(PCI_DEV(0, 0x00, 0)); |
| 85 | #endif |
Ed Swierk | b8e53eb | 2008-10-13 23:18:56 +0000 | [diff] [blame] | 86 | } |