blob: 0032fd67153698b61e93d6bda497f202560e5048 [file] [log] [blame]
Martin Roth58562402015-10-11 10:36:26 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google Inc.
5 * Copyright (C) 2013-2014 Sage Electronic Engineering, LLC.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Martin Roth58562402015-10-11 10:36:26 +020015 */
16
17#include <stdint.h>
18#include <string.h>
19#include <lib.h>
20#include <timestamp.h>
21#include <arch/io.h>
22#include <device/pci_def.h>
23#include <device/pnp_def.h>
24#include <cpu/x86/lapic.h>
Martin Roth58562402015-10-11 10:36:26 +020025#include <cbmem.h>
26#include <console/console.h>
Kyösti Mälkki63649d22018-12-29 09:40:40 +020027#include <console/usb.h>
Martin Roth58562402015-10-11 10:36:26 +020028#include <drivers/intel/fsp1_0/fsp_util.h>
Kyösti Mälkki65e8f642016-06-27 11:27:56 +030029#include <program_loading.h>
Elyes HAOUAS65bb5432018-07-03 14:59:50 +020030#include <northbridge/intel/fsp_rangeley/northbridge.h>
Martin Roth58562402015-10-11 10:36:26 +020031#include "southbridge/intel/fsp_rangeley/soc.h"
32#include "southbridge/intel/fsp_rangeley/gpio.h"
33#include "southbridge/intel/fsp_rangeley/romstage.h"
Martin Roth58562402015-10-11 10:36:26 +020034#include <cpu/x86/msr.h>
35#include "gpio.h"
36
37void main(FSP_INFO_HEADER *fsp_info_header)
38{
39 uint32_t fd_mask = 0;
40 uint32_t *func_dis = (uint32_t *)(DEFAULT_PBASE + PBASE_FUNC_DIS);
41
42 /*
43 * Do not use the Serial Console before it is setup.
44 * This causes the I/O to clog and a side effect is
45 * that the reset button stops functioning. So
46 * instead just use outb so it doesn't output to the
47 * console when CONFIG_CONSOLE_POST.
48 */
49 outb(0x40, 0x80);
50
51 timestamp_init(get_initial_timestamp());
52 timestamp_add_now(TS_START_ROMSTAGE);
53
54 /* Rangeley UART POR state is enabled */
55 console_init();
56 post_code(0x41);
57
58 /* Enable GPIOs BAR */
59 pci_write_config32(SOC_LPC_DEV, GBASE, DEFAULT_GPIOBASE|0x02);
60
61 early_mainboard_romstage_entry();
62
63 post_code(0x42);
64 rangeley_sb_early_initialization();
65
66 post_code(0x46);
67 /* Program any required function disables */
68 get_func_disables(&fd_mask);
69
70 if (fd_mask != 0) {
71 write32(func_dis, read32(func_dis) | fd_mask);
72 /* Ensure posted write hits. */
73 read32(func_dis);
74 }
75
76 timestamp_add_now(TS_BEFORE_INITRAM);
77
78 /*
79 * Call early init to initialize memory and chipset. This function returns
80 * to the romstage_main_continue function with a pointer to the HOB
81 * structure.
82 */
83 post_code(0x47);
84 printk(BIOS_DEBUG, "Starting the Intel FSP (early_init)\n");
85 fsp_early_init(fsp_info_header);
86 die("Uh Oh! fsp_early_init should not return here.\n");
87}
88
89/*******************************************************************************
90 * The FSP early_init function returns to this function.
91 * Memory is setup and the stack is set by the FSP.
92 */
93void romstage_main_continue(EFI_STATUS status, void *hob_list_ptr) {
94 int cbmem_was_initted;
95 void *cbmem_hob_ptr;
96
97 timestamp_add_now(TS_AFTER_INITRAM);
98
99 post_code(0x48);
100 printk(BIOS_DEBUG, "%s status: %x hob_list_ptr: %x\n",
101 __func__, (u32) status, (u32) hob_list_ptr);
102
Martin Roth58562402015-10-11 10:36:26 +0200103 /* FSP reconfigures USB, so reinit it to have debug */
Arthur Heymansadc47532018-12-28 15:48:58 +0100104 if (IS_ENABLED(CONFIG_USBDEBUG_IN_PRE_RAM))
Kyösti Mälkki63649d22018-12-29 09:40:40 +0200105 usbdebug_hw_init(true);
Martin Roth58562402015-10-11 10:36:26 +0200106
107 printk(BIOS_DEBUG, "FSP Status: 0x%0x\n", (u32)status);
108
109 post_code(0x4b);
110 late_mainboard_romstage_entry();
111
112 post_code(0x4c);
113
114 /* Decode E0000 and F0000 segment to DRAM */
115 sideband_write(B_UNIT, BMISC, sideband_read(B_UNIT, BMISC) | (1 << 1) | (1 << 0));
116
117 quick_ram_check();
118 post_code(0x4d);
119
120 cbmem_was_initted = !cbmem_recovery(0);
121
122 /* Save the HOB pointer in CBMEM to be used in ramstage*/
Martin Roth4fb64d02017-01-10 11:15:13 -0700123 cbmem_hob_ptr = cbmem_add(CBMEM_ID_HOB_POINTER, sizeof(*hob_list_ptr));
124 if (cbmem_hob_ptr == NULL)
125 die("Could not allocate cbmem for HOB pointer");
Martin Roth58562402015-10-11 10:36:26 +0200126 *(u32*)cbmem_hob_ptr = (u32)hob_list_ptr;
127 post_code(0x4e);
128
129 post_code(0x4f);
130
131 /* Load the ramstage. */
Kyösti Mälkki65e8f642016-06-27 11:27:56 +0300132 run_ramstage();
Martin Roth58562402015-10-11 10:36:26 +0200133 while (1);
134}
135
136uint64_t get_initial_timestamp(void)
137{
138 return 0;
139}