Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2015 Damien Zammit <damien@zamaudio.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 | |
| 16 | /* Platform has no romstage entry point under mainboard directory, |
| 17 | * so this one is named with prefix mainboard. |
| 18 | */ |
| 19 | |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 20 | #include <timestamp.h> |
| 21 | #include <console/console.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 22 | #include <device/pci_ops.h> |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 23 | #include <cbmem.h> |
Elyes HAOUAS | 363b771 | 2019-04-28 18:07:02 +0200 | [diff] [blame] | 24 | #include <cf9_reset.h> |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 25 | #include <romstage_handoff.h> |
| 26 | #include <southbridge/intel/i82801gx/i82801gx.h> |
| 27 | #include <southbridge/intel/common/gpio.h> |
Patrick Rudolph | 425e75a | 2019-03-24 15:06:17 +0100 | [diff] [blame] | 28 | #include <southbridge/intel/common/pmclib.h> |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 29 | #include <cpu/intel/romstage.h> |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 30 | #include <cpu/x86/lapic.h> |
| 31 | #include "raminit.h" |
| 32 | #include "pineview.h" |
| 33 | |
| 34 | static void rcba_config(void) |
| 35 | { |
| 36 | /* Set up virtual channel 0 */ |
| 37 | RCBA32(0x0014) = 0x80000001; |
| 38 | RCBA32(0x001c) = 0x03128010; |
| 39 | |
| 40 | /* Enable IOAPIC */ |
| 41 | RCBA8(OIC) = 0x03; |
| 42 | } |
| 43 | |
| 44 | __weak void mb_pirq_setup(void) |
| 45 | { |
| 46 | } |
| 47 | |
| 48 | #define LPC_DEV PCI_DEV(0x0, 0x1f, 0x0) |
| 49 | |
Kyösti Mälkki | 157b189 | 2019-08-16 14:02:25 +0300 | [diff] [blame] | 50 | void mainboard_romstage_entry(void) |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 51 | { |
| 52 | u8 spd_addrmap[4] = {}; |
| 53 | int boot_path, cbmem_was_initted; |
| 54 | int s3resume = 0; |
| 55 | |
Kyösti Mälkki | 157b189 | 2019-08-16 14:02:25 +0300 | [diff] [blame] | 56 | enable_lapic(); |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 57 | |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 58 | /* Enable GPIOs */ |
| 59 | pci_write_config32(LPC_DEV, GPIO_BASE, DEFAULT_GPIOBASE | 1); |
| 60 | pci_write_config8(LPC_DEV, GPIO_CNTL, 0x10); |
| 61 | |
| 62 | setup_pch_gpios(&mainboard_gpio_map); |
| 63 | |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 64 | enable_smbus(); |
| 65 | |
| 66 | /* Perform some early chipset initialization required |
| 67 | * before RAM initialization can work |
| 68 | */ |
| 69 | pineview_early_initialization(); |
| 70 | |
| 71 | post_code(0x30); |
| 72 | |
| 73 | s3resume = southbridge_detect_s3_resume(); |
| 74 | |
| 75 | if (s3resume) { |
| 76 | boot_path = BOOT_PATH_RESUME; |
| 77 | } else { |
| 78 | if (MCHBAR32(0xf14) & (1 << 8)) /* HOT RESET */ |
| 79 | boot_path = BOOT_PATH_RESET; |
| 80 | else |
| 81 | boot_path = BOOT_PATH_NORMAL; |
| 82 | } |
| 83 | |
| 84 | get_mb_spd_addrmap(&spd_addrmap[0]); |
| 85 | |
| 86 | printk(BIOS_DEBUG, "Initializing memory\n"); |
| 87 | timestamp_add_now(TS_BEFORE_INITRAM); |
| 88 | sdram_initialize(boot_path, spd_addrmap); |
| 89 | timestamp_add_now(TS_AFTER_INITRAM); |
| 90 | printk(BIOS_DEBUG, "Memory initialized\n"); |
| 91 | |
| 92 | post_code(0x31); |
| 93 | |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 94 | mb_pirq_setup(); |
| 95 | |
| 96 | rcba_config(); |
| 97 | |
| 98 | cbmem_was_initted = !cbmem_recovery(s3resume); |
| 99 | |
| 100 | if (!cbmem_was_initted && s3resume) { |
| 101 | /* Failed S3 resume, reset to come up cleanly */ |
Elyes HAOUAS | 363b771 | 2019-04-28 18:07:02 +0200 | [diff] [blame] | 102 | system_reset(); |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | romstage_handoff_init(s3resume); |
| 106 | } |