Johannes Hahn | 377153d | 2023-04-26 17:56:37 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <baseboard/variants.h> |
| 4 | #include <console/console.h> |
| 5 | #include <device/dram/common.h> |
| 6 | #include <device/mmio.h> |
| 7 | #include <hwilib.h> |
| 8 | #include <soc/meminit.h> |
| 9 | #include <soc/romstage.h> |
| 10 | #include <string.h> |
| 11 | #include <types.h> |
| 12 | |
| 13 | void mainboard_memory_init_params(FSPM_UPD *memupd) |
| 14 | { |
| 15 | static struct spd_info spd_info; |
| 16 | const struct mb_cfg *board_cfg = variant_memcfg_config(); |
| 17 | static uint8_t spd_data[CONFIG_DIMM_SPD_SIZE]; |
| 18 | const char *cbfs_hwi_name = "hwinfo.hex"; |
| 19 | |
| 20 | /* Initialize SPD information for LPDDR4x from HW-Info primarily with a fallback to |
| 21 | spd.bin in the case where the SPD data in HW-Info is not available or invalid. */ |
| 22 | memset(spd_data, 0, sizeof(spd_data)); |
| 23 | if ((hwilib_find_blocks(cbfs_hwi_name) == CB_SUCCESS) && |
| 24 | (hwilib_get_field(SPD, spd_data, 0x80) == 0x80) && |
| 25 | (ddr_crc16(spd_data, 126) == read16((void *)&spd_data[126]))) { |
| 26 | spd_info.spd_spec.spd_data_ptr_info.spd_data_ptr = (uintptr_t)spd_data; |
| 27 | spd_info.spd_spec.spd_data_ptr_info.spd_data_len = CONFIG_DIMM_SPD_SIZE; |
| 28 | spd_info.read_type = READ_SPD_MEMPTR; |
| 29 | } else { |
| 30 | die("SPD in HW-Info not valid!\n"); |
| 31 | } |
| 32 | /* Initialize variant specific configurations */ |
| 33 | memcfg_init(&memupd->FspmConfig, board_cfg, &spd_info, false); |
| 34 | |
| 35 | /* Enable Row-Hammer prevention */ |
| 36 | memupd->FspmConfig.RhPrevention = 1; |
| 37 | } |