Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 1 | /* |
| 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 Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <cbfs.h> |
| 19 | #include <console/console.h> |
| 20 | #include <string.h> |
| 21 | #include <ec/google/chromeec/ec.h> |
pchandri | e57e726 | 2015-09-14 14:11:38 -0700 | [diff] [blame] | 22 | #include <gpio.h> |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 23 | #include <soc/pei_data.h> |
| 24 | #include <soc/pei_wrapper.h> |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 25 | #include <soc/romstage.h> |
Wenkai Du | 1105fad | 2015-08-21 13:11:00 -0700 | [diff] [blame] | 26 | #include "gpio.h" |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 27 | #include "spd/spd.h" |
| 28 | |
Wenkai Du | 1105fad | 2015-08-21 13:11:00 -0700 | [diff] [blame] | 29 | static 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 Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 37 | void mainboard_romstage_entry(struct romstage_params *params) |
| 38 | { |
pchandri | e57e726 | 2015-09-14 14:11:38 -0700 | [diff] [blame] | 39 | /* 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 Laurie | 963bfa7 | 2015-09-04 10:29:58 -0700 | [diff] [blame] | 47 | /* Ensure the EC and PD are in the right mode for recovery */ |
| 48 | google_chromeec_early_init(); |
| 49 | |
Wenkai Du | 1105fad | 2015-08-21 13:11:00 -0700 | [diff] [blame] | 50 | early_config_gpio(); |
| 51 | |
pchandri | e57e726 | 2015-09-14 14:11:38 -0700 | [diff] [blame] | 52 | params->pei_data->mem_cfg_id = gpio_base2_value(spd_gpios, |
| 53 | ARRAY_SIZE(spd_gpios)); |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 54 | /* 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 Laurie | 74b964e | 2015-09-04 10:41:02 -0700 | [diff] [blame] | 61 | void mainboard_memory_init_params(struct romstage_params *params, |
| 62 | MEMORY_INIT_UPD *memory_params) |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 63 | { |
| 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 Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 69 | } |
| 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 | } |