Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Google Inc. |
Lee Leahy | a608969 | 2016-01-05 16:34:58 -0800 | [diff] [blame] | 5 | * Copyright (C) 2015-2016 Intel Corporation. |
Frans Hendriks | 44d2c85 | 2018-12-03 10:40:06 +0100 | [diff] [blame] | 6 | * Copyright (C) 2018 Eltan B.V. |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 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 | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <stddef.h> |
Aaron Durbin | 932e09d | 2016-07-13 23:09:52 -0500 | [diff] [blame] | 19 | #include <arch/acpi.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 20 | #include <arch/cbfs.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 21 | #include <arch/early_variables.h> |
Aaron Durbin | 31be2c9 | 2016-12-03 22:08:20 -0600 | [diff] [blame] | 22 | #include <assert.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 23 | #include <console/console.h> |
| 24 | #include <cbmem.h> |
Patrick Rudolph | f677d17 | 2018-10-01 19:17:11 +0200 | [diff] [blame] | 25 | #include <cf9_reset.h> |
robbie zhang | 13a2e94 | 2016-02-10 11:40:11 -0800 | [diff] [blame] | 26 | #include <cpu/intel/microcode.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 27 | #include <cpu/x86/mtrr.h> |
| 28 | #include <ec/google/chromeec/ec.h> |
| 29 | #include <ec/google/chromeec/ec_commands.h> |
| 30 | #include <elog.h> |
Lee Leahy | b092c9e | 2016-01-01 18:09:50 -0800 | [diff] [blame] | 31 | #include <fsp/romstage.h> |
Aaron Durbin | decd062 | 2017-12-15 12:26:40 -0700 | [diff] [blame] | 32 | #include <mrc_cache.h> |
Kyösti Mälkki | 65e8f64 | 2016-06-27 11:27:56 +0300 | [diff] [blame] | 33 | #include <program_loading.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 34 | #include <romstage_handoff.h> |
Lee Leahy | 0be6d93 | 2015-06-26 11:15:42 -0700 | [diff] [blame] | 35 | #include <smbios.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 36 | #include <stage_cache.h> |
Aaron Durbin | afe8aee | 2016-11-29 21:37:42 -0600 | [diff] [blame] | 37 | #include <string.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 38 | #include <timestamp.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 39 | #include <vendorcode/google/chromeos/chromeos.h> |
| 40 | |
Aaron Durbin | e6af4be | 2015-09-24 12:26:31 -0500 | [diff] [blame] | 41 | asmlinkage void *romstage_main(FSP_INFO_HEADER *fih) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 42 | { |
| 43 | void *top_of_stack; |
| 44 | struct pei_data pei_data; |
| 45 | struct romstage_params params = { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 46 | .pei_data = &pei_data, |
Aaron Durbin | e6af4be | 2015-09-24 12:26:31 -0500 | [diff] [blame] | 47 | .chipset_context = fih, |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | post_code(0x30); |
| 51 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 52 | timestamp_add_now(TS_START_ROMSTAGE); |
| 53 | |
Elyes HAOUAS | 7753731 | 2016-07-30 15:37:26 +0200 | [diff] [blame] | 54 | /* Load microcode before RAM init */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 55 | if (CONFIG(SUPPORT_CPU_UCODE_IN_CBFS)) |
robbie zhang | 13a2e94 | 2016-02-10 11:40:11 -0800 | [diff] [blame] | 56 | intel_update_microcode_from_cbfs(); |
| 57 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 58 | memset(&pei_data, 0, sizeof(pei_data)); |
| 59 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 60 | /* Display parameters */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 61 | if (!CONFIG(NO_MMCONF_SUPPORT)) |
Lee Leahy | c253a92 | 2017-03-13 17:36:39 -0700 | [diff] [blame] | 62 | printk(BIOS_SPEW, "CONFIG_MMCONF_BASE_ADDRESS: 0x%08x\n", |
| 63 | CONFIG_MMCONF_BASE_ADDRESS); |
Aaron Durbin | 929b602 | 2015-12-09 16:00:18 -0600 | [diff] [blame] | 64 | printk(BIOS_INFO, "Using FSP 1.1\n"); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 65 | |
| 66 | /* Display FSP banner */ |
Aaron Durbin | e6af4be | 2015-09-24 12:26:31 -0500 | [diff] [blame] | 67 | print_fsp_info(fih); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 68 | |
Aaron Durbin | 929b602 | 2015-12-09 16:00:18 -0600 | [diff] [blame] | 69 | /* Stash FSP version. */ |
| 70 | params.fsp_version = fsp_version(fih); |
| 71 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 72 | /* Get power state */ |
| 73 | params.power_state = fill_power_state(); |
| 74 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 75 | /* Call into mainboard. */ |
| 76 | mainboard_romstage_entry(¶ms); |
| 77 | soc_after_ram_init(¶ms); |
| 78 | post_code(0x38); |
| 79 | |
| 80 | top_of_stack = setup_stack_and_mtrrs(); |
| 81 | |
Lee Leahy | 3e5bc1f | 2015-06-24 11:17:54 -0700 | [diff] [blame] | 82 | printk(BIOS_DEBUG, "Calling FspTempRamExit API\n"); |
| 83 | timestamp_add_now(TS_FSP_TEMP_RAM_EXIT_START); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 84 | return top_of_stack; |
| 85 | } |
| 86 | |
Aaron Durbin | e6af4be | 2015-09-24 12:26:31 -0500 | [diff] [blame] | 87 | void *cache_as_ram_stage_main(FSP_INFO_HEADER *fih) |
| 88 | { |
| 89 | return romstage_main(fih); |
| 90 | } |
| 91 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 92 | /* Entry from the mainboard. */ |
| 93 | void romstage_common(struct romstage_params *params) |
| 94 | { |
Subrata Banik | 0beac81 | 2017-07-12 15:13:53 +0530 | [diff] [blame] | 95 | bool s3wake; |
Aaron Durbin | 31be2c9 | 2016-12-03 22:08:20 -0600 | [diff] [blame] | 96 | struct region_device rdev; |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 97 | struct pei_data *pei_data; |
| 98 | |
| 99 | post_code(0x32); |
| 100 | |
| 101 | timestamp_add_now(TS_BEFORE_INITRAM); |
| 102 | |
| 103 | pei_data = params->pei_data; |
Subrata Banik | 0beac81 | 2017-07-12 15:13:53 +0530 | [diff] [blame] | 104 | s3wake = params->power_state->prev_sleep_state == ACPI_S3; |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 105 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 106 | if (CONFIG(ELOG_BOOT_COUNT) && !s3wake) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 107 | boot_count_increment(); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 108 | |
| 109 | /* Perform remaining SOC initialization */ |
| 110 | soc_pre_ram_init(params); |
| 111 | post_code(0x33); |
| 112 | |
| 113 | /* Check recovery and MRC cache */ |
| 114 | params->pei_data->saved_data_size = 0; |
| 115 | params->pei_data->saved_data = NULL; |
| 116 | if (!params->pei_data->disable_saved_data) { |
Furquan Shaikh | 0325dc6 | 2016-07-25 13:02:36 -0700 | [diff] [blame] | 117 | if (vboot_recovery_mode_enabled()) { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 118 | /* Recovery mode does not use MRC cache */ |
| 119 | printk(BIOS_DEBUG, |
| 120 | "Recovery mode: not using MRC cache.\n"); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 121 | } else if (CONFIG(CACHE_MRC_SETTINGS) |
Aaron Durbin | 31be2c9 | 2016-12-03 22:08:20 -0600 | [diff] [blame] | 122 | && (!mrc_cache_get_current(MRC_TRAINING_DATA, |
| 123 | params->fsp_version, |
| 124 | &rdev))) { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 125 | /* MRC cache found */ |
Aaron Durbin | 31be2c9 | 2016-12-03 22:08:20 -0600 | [diff] [blame] | 126 | params->pei_data->saved_data_size = |
| 127 | region_device_sz(&rdev); |
| 128 | params->pei_data->saved_data = rdev_mmap_full(&rdev); |
Elyes HAOUAS | 1895838 | 2018-08-07 12:23:16 +0200 | [diff] [blame] | 129 | /* Assume boot device is memory mapped. */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 130 | assert(CONFIG(BOOT_DEVICE_MEMORY_MAPPED)); |
Nico Huber | 16895c5 | 2019-05-04 16:29:17 +0200 | [diff] [blame^] | 131 | } else if (s3wake) { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 132 | /* Waking from S3 and no cache. */ |
| 133 | printk(BIOS_DEBUG, |
| 134 | "No MRC cache found in S3 resume path.\n"); |
| 135 | post_code(POST_RESUME_FAILURE); |
Patrick Rudolph | f677d17 | 2018-10-01 19:17:11 +0200 | [diff] [blame] | 136 | /* FIXME: A "system" reset is likely enough: */ |
| 137 | full_reset(); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 138 | } else { |
| 139 | printk(BIOS_DEBUG, "No MRC cache found.\n"); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 140 | } |
| 141 | } |
| 142 | |
| 143 | /* Initialize RAM */ |
| 144 | raminit(params); |
| 145 | timestamp_add_now(TS_AFTER_INITRAM); |
| 146 | |
| 147 | /* Save MRC output */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 148 | if (CONFIG(CACHE_MRC_SETTINGS)) { |
Lee Leahy | a608969 | 2016-01-05 16:34:58 -0800 | [diff] [blame] | 149 | printk(BIOS_DEBUG, "MRC data at %p %d bytes\n", |
| 150 | pei_data->data_to_save, pei_data->data_to_save_size); |
Nico Huber | 16895c5 | 2019-05-04 16:29:17 +0200 | [diff] [blame^] | 151 | if (!s3wake |
Lee Leahy | a608969 | 2016-01-05 16:34:58 -0800 | [diff] [blame] | 152 | && (params->pei_data->data_to_save_size != 0) |
| 153 | && (params->pei_data->data_to_save != NULL)) |
Lee Leahy | 216712a | 2017-03-17 11:23:32 -0700 | [diff] [blame] | 154 | mrc_cache_stash_data(MRC_TRAINING_DATA, |
| 155 | params->fsp_version, |
| 156 | params->pei_data->data_to_save, |
| 157 | params->pei_data->data_to_save_size); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | /* Save DIMM information */ |
Subrata Banik | 0beac81 | 2017-07-12 15:13:53 +0530 | [diff] [blame] | 161 | if (!s3wake) |
| 162 | mainboard_save_dimm_info(params); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 163 | |
| 164 | /* Create romstage handof information */ |
Aaron Durbin | 77e1399 | 2016-11-29 17:43:04 -0600 | [diff] [blame] | 165 | if (romstage_handoff_init( |
| 166 | params->power_state->prev_sleep_state == ACPI_S3) < 0) |
Patrick Rudolph | f677d17 | 2018-10-01 19:17:11 +0200 | [diff] [blame] | 167 | /* FIXME: A "system" reset is likely enough: */ |
| 168 | full_reset(); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Aaron Durbin | e6af4be | 2015-09-24 12:26:31 -0500 | [diff] [blame] | 171 | void after_cache_as_ram_stage(void) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 172 | { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 173 | /* Load the ramstage. */ |
Kyösti Mälkki | 65e8f64 | 2016-06-27 11:27:56 +0300 | [diff] [blame] | 174 | run_ramstage(); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 175 | die("ERROR - Failed to load ramstage!"); |
| 176 | } |
| 177 | |
| 178 | /* Initialize the power state */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 179 | __weak struct chipset_power_state *fill_power_state(void) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 180 | { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 181 | return NULL; |
| 182 | } |
| 183 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 184 | /* Board initialization before and after RAM is enabled */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 185 | __weak void mainboard_romstage_entry( |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 186 | struct romstage_params *params) |
| 187 | { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 188 | post_code(0x31); |
| 189 | |
Frans Hendriks | 44d2c85 | 2018-12-03 10:40:06 +0100 | [diff] [blame] | 190 | /* Initialize memory */ |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 191 | romstage_common(params); |
| 192 | } |
| 193 | |
| 194 | /* Save the DIMM information for SMBIOS table 17 */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 195 | __weak void mainboard_save_dimm_info( |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 196 | struct romstage_params *params) |
| 197 | { |
| 198 | int channel; |
| 199 | CHANNEL_INFO *channel_info; |
| 200 | int dimm; |
| 201 | DIMM_INFO *dimm_info; |
| 202 | int dimm_max; |
| 203 | void *hob_list_ptr; |
| 204 | EFI_HOB_GUID_TYPE *hob_ptr; |
| 205 | int index; |
| 206 | struct memory_info *mem_info; |
| 207 | FSP_SMBIOS_MEMORY_INFO *memory_info_hob; |
| 208 | const EFI_GUID memory_info_hob_guid = FSP_SMBIOS_MEMORY_INFO_GUID; |
| 209 | |
| 210 | /* Locate the memory info HOB, presence validated by raminit */ |
| 211 | hob_list_ptr = fsp_get_hob_list(); |
| 212 | hob_ptr = get_next_guid_hob(&memory_info_hob_guid, hob_list_ptr); |
| 213 | memory_info_hob = (FSP_SMBIOS_MEMORY_INFO *)(hob_ptr + 1); |
| 214 | |
| 215 | /* Display the data in the FSP_SMBIOS_MEMORY_INFO HOB */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 216 | if (CONFIG(DISPLAY_HOBS)) { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 217 | printk(BIOS_DEBUG, "FSP_SMBIOS_MEMORY_INFO HOB\n"); |
| 218 | printk(BIOS_DEBUG, " 0x%02x: Revision\n", |
| 219 | memory_info_hob->Revision); |
| 220 | printk(BIOS_DEBUG, " 0x%02x: MemoryType\n", |
| 221 | memory_info_hob->MemoryType); |
Lee Leahy | 0be6d93 | 2015-06-26 11:15:42 -0700 | [diff] [blame] | 222 | printk(BIOS_DEBUG, " %d: MemoryFrequencyInMHz\n", |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 223 | memory_info_hob->MemoryFrequencyInMHz); |
Lee Leahy | 0be6d93 | 2015-06-26 11:15:42 -0700 | [diff] [blame] | 224 | printk(BIOS_DEBUG, " %d: DataWidth in bits\n", |
| 225 | memory_info_hob->DataWidth); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 226 | printk(BIOS_DEBUG, " 0x%02x: ErrorCorrectionType\n", |
| 227 | memory_info_hob->ErrorCorrectionType); |
| 228 | printk(BIOS_DEBUG, " 0x%02x: ChannelCount\n", |
| 229 | memory_info_hob->ChannelCount); |
| 230 | for (channel = 0; channel < memory_info_hob->ChannelCount; |
| 231 | channel++) { |
| 232 | channel_info = &memory_info_hob->ChannelInfo[channel]; |
| 233 | printk(BIOS_DEBUG, " Channel %d\n", channel); |
| 234 | printk(BIOS_DEBUG, " 0x%02x: ChannelId\n", |
| 235 | channel_info->ChannelId); |
| 236 | printk(BIOS_DEBUG, " 0x%02x: DimmCount\n", |
| 237 | channel_info->DimmCount); |
| 238 | for (dimm = 0; dimm < channel_info->DimmCount; |
| 239 | dimm++) { |
| 240 | dimm_info = &channel_info->DimmInfo[dimm]; |
| 241 | printk(BIOS_DEBUG, " DIMM %d\n", dimm); |
| 242 | printk(BIOS_DEBUG, " 0x%02x: DimmId\n", |
| 243 | dimm_info->DimmId); |
Lee Leahy | 0be6d93 | 2015-06-26 11:15:42 -0700 | [diff] [blame] | 244 | printk(BIOS_DEBUG, " %d: SizeInMb\n", |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 245 | dimm_info->SizeInMb); |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | /* |
| 251 | * Allocate CBMEM area for DIMM information used to populate SMBIOS |
| 252 | * table 17 |
| 253 | */ |
| 254 | mem_info = cbmem_add(CBMEM_ID_MEMINFO, sizeof(*mem_info)); |
| 255 | printk(BIOS_DEBUG, "CBMEM entry for DIMM info: 0x%p\n", mem_info); |
| 256 | if (mem_info == NULL) |
| 257 | return; |
| 258 | memset(mem_info, 0, sizeof(*mem_info)); |
| 259 | |
| 260 | /* Describe the first N DIMMs in the system */ |
| 261 | index = 0; |
| 262 | dimm_max = ARRAY_SIZE(mem_info->dimm); |
| 263 | for (channel = 0; channel < memory_info_hob->ChannelCount; channel++) { |
| 264 | if (index >= dimm_max) |
| 265 | break; |
| 266 | channel_info = &memory_info_hob->ChannelInfo[channel]; |
| 267 | for (dimm = 0; dimm < channel_info->DimmCount; dimm++) { |
| 268 | if (index >= dimm_max) |
| 269 | break; |
| 270 | dimm_info = &channel_info->DimmInfo[dimm]; |
| 271 | |
| 272 | /* Populate the DIMM information */ |
| 273 | if (dimm_info->SizeInMb) { |
| 274 | mem_info->dimm[index].dimm_size = |
| 275 | dimm_info->SizeInMb; |
| 276 | mem_info->dimm[index].ddr_type = |
| 277 | memory_info_hob->MemoryType; |
| 278 | mem_info->dimm[index].ddr_frequency = |
| 279 | memory_info_hob->MemoryFrequencyInMHz; |
| 280 | mem_info->dimm[index].channel_num = |
| 281 | channel_info->ChannelId; |
| 282 | mem_info->dimm[index].dimm_num = |
| 283 | dimm_info->DimmId; |
Lee Leahy | 0be6d93 | 2015-06-26 11:15:42 -0700 | [diff] [blame] | 284 | switch (memory_info_hob->DataWidth) { |
| 285 | default: |
| 286 | case 8: |
| 287 | mem_info->dimm[index].bus_width = |
| 288 | MEMORY_BUS_WIDTH_8; |
| 289 | break; |
| 290 | |
| 291 | case 16: |
| 292 | mem_info->dimm[index].bus_width = |
| 293 | MEMORY_BUS_WIDTH_16; |
| 294 | break; |
| 295 | |
| 296 | case 32: |
| 297 | mem_info->dimm[index].bus_width = |
| 298 | MEMORY_BUS_WIDTH_32; |
| 299 | break; |
| 300 | |
| 301 | case 64: |
| 302 | mem_info->dimm[index].bus_width = |
| 303 | MEMORY_BUS_WIDTH_64; |
| 304 | break; |
| 305 | |
| 306 | case 128: |
| 307 | mem_info->dimm[index].bus_width = |
| 308 | MEMORY_BUS_WIDTH_128; |
| 309 | break; |
| 310 | } |
Duncan Laurie | 46a2c77 | 2015-07-20 16:48:55 -0700 | [diff] [blame] | 311 | |
| 312 | /* Add any mainboard specific information */ |
| 313 | mainboard_add_dimm_info(params, mem_info, |
| 314 | channel, dimm, index); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 315 | index++; |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | mem_info->dimm_cnt = index; |
| 320 | printk(BIOS_DEBUG, "%d DIMMs found\n", mem_info->dimm_cnt); |
| 321 | } |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 322 | |
Duncan Laurie | 46a2c77 | 2015-07-20 16:48:55 -0700 | [diff] [blame] | 323 | /* Add any mainboard specific information */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 324 | __weak void mainboard_add_dimm_info( |
Duncan Laurie | 46a2c77 | 2015-07-20 16:48:55 -0700 | [diff] [blame] | 325 | struct romstage_params *params, |
| 326 | struct memory_info *mem_info, |
| 327 | int channel, int dimm, int index) |
| 328 | { |
Duncan Laurie | 46a2c77 | 2015-07-20 16:48:55 -0700 | [diff] [blame] | 329 | } |
| 330 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 331 | /* Get the memory configuration data */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 332 | __weak int mrc_cache_get_current(int type, uint32_t version, |
Aaron Durbin | 31be2c9 | 2016-12-03 22:08:20 -0600 | [diff] [blame] | 333 | struct region_device *rdev) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 334 | { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 335 | return -1; |
| 336 | } |
| 337 | |
| 338 | /* Save the memory configuration data */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 339 | __weak int mrc_cache_stash_data(int type, uint32_t version, |
Aaron Durbin | 31be2c9 | 2016-12-03 22:08:20 -0600 | [diff] [blame] | 340 | const void *data, size_t size) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 341 | { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 342 | return -1; |
| 343 | } |
| 344 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 345 | /* Display the memory configuration */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 346 | __weak void report_memory_config(void) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 347 | { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 348 | } |
| 349 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 350 | /* Choose top of stack and setup MTRRs */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 351 | __weak void *setup_stack_and_mtrrs(void) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 352 | { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 353 | die("ERROR - Must specify top of stack!\n"); |
| 354 | return NULL; |
| 355 | } |
| 356 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 357 | /* SOC initialization after RAM is enabled */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 358 | __weak void soc_after_ram_init(struct romstage_params *params) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 359 | { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 360 | } |
| 361 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 362 | /* SOC initialization before RAM is enabled */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 363 | __weak void soc_pre_ram_init(struct romstage_params *params) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 364 | { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 365 | } |