Werner Zeh | e5a1fc7 | 2021-07-01 13:40:11 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Werner Zeh | 59a8355 | 2021-10-07 16:12:06 +0200 | [diff] [blame] | 3 | #include <arch/mmio.h> |
Werner Zeh | e5a1fc7 | 2021-07-01 13:40:11 +0200 | [diff] [blame] | 4 | #include <baseboard/variants.h> |
Werner Zeh | 59a8355 | 2021-10-07 16:12:06 +0200 | [diff] [blame] | 5 | #include <console/console.h> |
| 6 | #include <device/dram/common.h> |
| 7 | #include <hwilib.h> |
Werner Zeh | e5a1fc7 | 2021-07-01 13:40:11 +0200 | [diff] [blame] | 8 | #include <soc/meminit.h> |
| 9 | #include <soc/romstage.h> |
Werner Zeh | 59a8355 | 2021-10-07 16:12:06 +0200 | [diff] [blame] | 10 | #include <string.h> |
| 11 | #include <types.h> |
Werner Zeh | e5a1fc7 | 2021-07-01 13:40:11 +0200 | [diff] [blame] | 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(); |
Werner Zeh | 59a8355 | 2021-10-07 16:12:06 +0200 | [diff] [blame] | 17 | static uint8_t spd_data[0x100]; |
| 18 | const char *cbfs_hwi_name = "hwinfo.hex"; |
Werner Zeh | e5a1fc7 | 2021-07-01 13:40:11 +0200 | [diff] [blame] | 19 | |
Werner Zeh | 59a8355 | 2021-10-07 16:12:06 +0200 | [diff] [blame] | 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 = sizeof(spd_data); |
| 28 | spd_info.read_type = READ_SPD_MEMPTR; |
| 29 | } else { |
| 30 | printk(BIOS_WARNING, "SPD in HW-Info not valid, fall back to spd.bin!\n"); |
| 31 | spd_info.read_type = READ_SPD_CBFS; |
| 32 | spd_info.spd_spec.spd_index = 0x00; |
| 33 | } |
Werner Zeh | e5a1fc7 | 2021-07-01 13:40:11 +0200 | [diff] [blame] | 34 | /* Initialize variant specific configurations */ |
Werner Zeh | 9cae17d | 2021-10-07 16:22:51 +0200 | [diff] [blame] | 35 | memcfg_init(&memupd->FspmConfig, board_cfg, &spd_info, false); |
Mario Scheithauer | bb03e76 | 2021-11-02 14:39:17 +0100 | [diff] [blame] | 36 | |
| 37 | /* Enable Row-Hammer prevention */ |
| 38 | memupd->FspmConfig.RhPrevention = 1; |
Werner Zeh | e5a1fc7 | 2021-07-01 13:40:11 +0200 | [diff] [blame] | 39 | } |