Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 1 | /* |
| 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älkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <stdint.h> |
| 17 | #include <device/pci_def.h> |
| 18 | #include <arch/io.h> |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 19 | #include <arch/cpu.h> |
| 20 | #include <stdlib.h> |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame^] | 21 | #include <cbmem.h> |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 22 | #include <console/console.h> |
Kyösti Mälkki | 3aff1a3 | 2012-04-11 12:19:03 +0300 | [diff] [blame] | 23 | #include <cpu/x86/bist.h> |
Kyösti Mälkki | 408d392 | 2016-06-17 10:43:48 +0300 | [diff] [blame] | 24 | #include <cpu/intel/romstage.h> |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 25 | |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 26 | #include <southbridge/intel/i82801dx/i82801dx.h> |
| 27 | #include <northbridge/intel/e7505/raminit.h> |
Kyösti Mälkki | 93b4ed9 | 2012-04-18 21:13:33 +0300 | [diff] [blame] | 28 | |
| 29 | #include <device/pnp_def.h> |
Edward O'Callaghan | c3e77fc | 2015-01-04 16:24:14 +1100 | [diff] [blame] | 30 | #include <superio/smsc/lpc47m10x/lpc47m10x.h> |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 31 | |
| 32 | #define SERIAL_DEV PNP_DEV(0x2e, LPC47M10X2_SP1) |
| 33 | |
Kyösti Mälkki | 93b4ed9 | 2012-04-18 21:13:33 +0300 | [diff] [blame] | 34 | int spd_read_byte(unsigned device, unsigned address) |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 35 | { |
| 36 | return smbus_read_byte(device, address); |
| 37 | } |
| 38 | |
Kyösti Mälkki | 408d392 | 2016-06-17 10:43:48 +0300 | [diff] [blame] | 39 | void mainboard_romstage_entry(unsigned long bist) |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 40 | { |
| 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 HAOUAS | 4682986 | 2016-10-07 17:35:50 +0200 | [diff] [blame] | 50 | /* Get the serial port running and print a welcome banner */ |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 51 | lpc47m10x_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); |
| 52 | console_init(); |
| 53 | |
Elyes HAOUAS | 4682986 | 2016-10-07 17:35:50 +0200 | [diff] [blame] | 54 | /* Halt if there was a built in self test failure */ |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 55 | report_bist_failure(bist); |
| 56 | |
Elyes HAOUAS | 4682986 | 2016-10-07 17:35:50 +0200 | [diff] [blame] | 57 | /* If this is a warm boot, some initialization can be skipped */ |
Kyösti Mälkki | 93b4ed9 | 2012-04-18 21:13:33 +0300 | [diff] [blame] | 58 | if (!e7505_mch_is_ready()) { |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 59 | enable_smbus(); |
Kyösti Mälkki | 97c064f | 2012-04-18 20:33:35 +0300 | [diff] [blame] | 60 | |
| 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 Roth | f95911a | 2017-06-24 21:45:13 -0600 | [diff] [blame] | 69 | #if IS_ENABLED(CONFIG_HW_SCRUBBER) |
| 70 | #if !IS_ENABLED(CONFIG_USBDEBUG_IN_ROMSTAGE) |
Kyösti Mälkki | 97c064f | 2012-04-18 20:33:35 +0300 | [diff] [blame] | 71 | unsigned long ret_addr = (unsigned long)((unsigned long*)&bist - 1); |
| 72 | e7505_mch_scrub_ecc(ret_addr); |
| 73 | #endif |
Kyösti Mälkki | b7d7cfb | 2013-06-06 10:39:48 +0300 | [diff] [blame] | 74 | #endif |
Kyösti Mälkki | 97c064f | 2012-04-18 20:33:35 +0300 | [diff] [blame] | 75 | |
| 76 | /* Hook for post ECC scrub settings and debug. */ |
| 77 | e7505_mch_done(memctrl); |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 78 | } |
| 79 | |
Kyösti Mälkki | 97c064f | 2012-04-18 20:33:35 +0300 | [diff] [blame] | 80 | printk(BIOS_DEBUG, "SDRAM is up.\n"); |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame^] | 81 | |
| 82 | cbmem_recovery(0); |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 83 | } |