blob: a0eeafc9a573d8e7689fdc57d4c220abc6172078 [file] [log] [blame]
Lee Leahyc4210412015-06-29 11:37:56 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2010 coresystems GmbH
5 * Copyright (C) 2014 Google Inc.
6 * Copyright (C) 2015 Intel Corporation.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
Lee Leahyb993d2f2015-07-17 11:07:54 -070019 * Foundation, Inc.
Lee Leahyc4210412015-06-29 11:37:56 -070020 */
21
22#include <cbfs.h>
23#include <console/console.h>
24#include <string.h>
25#include <ec/google/chromeec/ec.h>
Lee Leahyc4210412015-06-29 11:37:56 -070026#include <soc/gpio.h>
27#include <soc/pei_data.h>
28#include <soc/pei_wrapper.h>
Lee Leahyc4210412015-06-29 11:37:56 -070029#include <soc/romstage.h>
Wenkai Du1105fad2015-08-21 13:11:00 -070030#include "gpio.h"
Lee Leahyc4210412015-06-29 11:37:56 -070031#include "spd/spd.h"
32
Wenkai Du1105fad2015-08-21 13:11:00 -070033static void early_config_gpio(void)
34{
35 /* This is a hack for FSP because it does things in MemoryInit()
36 * which it shouldn't be. We have to prepare certain gpios here
37 * because of the brokenness in FSP. */
38 gpio_configure_pads(early_gpio_table, ARRAY_SIZE(early_gpio_table));
39}
40
Lee Leahyc4210412015-06-29 11:37:56 -070041void mainboard_romstage_entry(struct romstage_params *params)
42{
Duncan Laurie963bfa72015-09-04 10:29:58 -070043 /* Ensure the EC and PD are in the right mode for recovery */
44 google_chromeec_early_init();
45
Wenkai Du1105fad2015-08-21 13:11:00 -070046 early_config_gpio();
47
Lee Leahyc4210412015-06-29 11:37:56 -070048 /* Fill out PEI DATA */
49 mainboard_fill_pei_data(params->pei_data);
50 mainboard_fill_spd_data(params->pei_data);
51 /* Initliaze memory */
52 romstage_common(params);
53}
54
Duncan Laurie74b964e2015-09-04 10:41:02 -070055void mainboard_memory_init_params(struct romstage_params *params,
56 MEMORY_INIT_UPD *memory_params)
Lee Leahyc4210412015-06-29 11:37:56 -070057{
58 if (params->pei_data->spd_data[0][0][0] != 0) {
59 memory_params->MemorySpdPtr00 =
60 (UINT32)(params->pei_data->spd_data[0][0]);
61 memory_params->MemorySpdPtr10 =
62 (UINT32)(params->pei_data->spd_data[1][0]);
Lee Leahyc4210412015-06-29 11:37:56 -070063 }
64 memcpy(memory_params->DqByteMapCh0, params->pei_data->dq_map[0],
65 sizeof(params->pei_data->dq_map[0]));
66 memcpy(memory_params->DqByteMapCh1, params->pei_data->dq_map[1],
67 sizeof(params->pei_data->dq_map[1]));
68 memcpy(memory_params->DqsMapCpu2DramCh0, params->pei_data->dqs_map[0],
69 sizeof(params->pei_data->dqs_map[0]));
70 memcpy(memory_params->DqsMapCpu2DramCh1, params->pei_data->dqs_map[1],
71 sizeof(params->pei_data->dqs_map[1]));
72 memcpy(memory_params->RcompResistor, params->pei_data->RcompResistor,
73 sizeof(params->pei_data->RcompResistor));
74 memcpy(memory_params->RcompTarget, params->pei_data->RcompTarget,
75 sizeof(params->pei_data->RcompTarget));
76 memory_params->MemorySpdDataLen = SPD_LEN;
77 memory_params->DqPinsInterleaved = FALSE;
78}