blob: 1d25c7fad9f96f4a62a8ce22618ecc40df3f698c [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.
Lee Leahyc4210412015-06-29 11:37:56 -070016 */
17
18#include <cbfs.h>
19#include <console/console.h>
20#include <string.h>
21#include <ec/google/chromeec/ec.h>
pchandrie57e7262015-09-14 14:11:38 -070022#include <gpio.h>
Lee Leahyc4210412015-06-29 11:37:56 -070023#include <soc/pei_data.h>
24#include <soc/pei_wrapper.h>
Lee Leahyc4210412015-06-29 11:37:56 -070025#include <soc/romstage.h>
Wenkai Du1105fad2015-08-21 13:11:00 -070026#include "gpio.h"
Lee Leahyc4210412015-06-29 11:37:56 -070027#include "spd/spd.h"
28
Wenkai Du1105fad2015-08-21 13:11:00 -070029static void early_config_gpio(void)
30{
31 /* This is a hack for FSP because it does things in MemoryInit()
32 * which it shouldn't be. We have to prepare certain gpios here
33 * because of the brokenness in FSP. */
34 gpio_configure_pads(early_gpio_table, ARRAY_SIZE(early_gpio_table));
35}
36
Lee Leahyc4210412015-06-29 11:37:56 -070037void mainboard_romstage_entry(struct romstage_params *params)
38{
pchandrie57e7262015-09-14 14:11:38 -070039 /* PCH_MEM_CFG[3:0] */
40 gpio_t spd_gpios[] = {
41 GPIO_MEM_CONFIG_0,
42 GPIO_MEM_CONFIG_1,
43 GPIO_MEM_CONFIG_2,
44 GPIO_MEM_CONFIG_3,
45 };
46
Duncan Laurie963bfa72015-09-04 10:29:58 -070047 /* Ensure the EC and PD are in the right mode for recovery */
48 google_chromeec_early_init();
49
Wenkai Du1105fad2015-08-21 13:11:00 -070050 early_config_gpio();
51
pchandrie57e7262015-09-14 14:11:38 -070052 params->pei_data->mem_cfg_id = gpio_base2_value(spd_gpios,
53 ARRAY_SIZE(spd_gpios));
Lee Leahyc4210412015-06-29 11:37:56 -070054 /* Fill out PEI DATA */
55 mainboard_fill_pei_data(params->pei_data);
56 mainboard_fill_spd_data(params->pei_data);
57 /* Initliaze memory */
58 romstage_common(params);
59}
60
Duncan Laurie74b964e2015-09-04 10:41:02 -070061void mainboard_memory_init_params(struct romstage_params *params,
62 MEMORY_INIT_UPD *memory_params)
Lee Leahyc4210412015-06-29 11:37:56 -070063{
64 if (params->pei_data->spd_data[0][0][0] != 0) {
65 memory_params->MemorySpdPtr00 =
66 (UINT32)(params->pei_data->spd_data[0][0]);
67 memory_params->MemorySpdPtr10 =
68 (UINT32)(params->pei_data->spd_data[1][0]);
Lee Leahyc4210412015-06-29 11:37:56 -070069 }
70 memcpy(memory_params->DqByteMapCh0, params->pei_data->dq_map[0],
71 sizeof(params->pei_data->dq_map[0]));
72 memcpy(memory_params->DqByteMapCh1, params->pei_data->dq_map[1],
73 sizeof(params->pei_data->dq_map[1]));
74 memcpy(memory_params->DqsMapCpu2DramCh0, params->pei_data->dqs_map[0],
75 sizeof(params->pei_data->dqs_map[0]));
76 memcpy(memory_params->DqsMapCpu2DramCh1, params->pei_data->dqs_map[1],
77 sizeof(params->pei_data->dqs_map[1]));
78 memcpy(memory_params->RcompResistor, params->pei_data->RcompResistor,
79 sizeof(params->pei_data->RcompResistor));
80 memcpy(memory_params->RcompTarget, params->pei_data->RcompTarget,
81 sizeof(params->pei_data->RcompTarget));
82 memory_params->MemorySpdDataLen = SPD_LEN;
83 memory_params->DqPinsInterleaved = FALSE;
84}