From f4bb77bd9eb576df0e16d261b1bf461512b784fd Mon Sep 17 00:00:00 2001 From: Xi Chen Date: Fri, 21 Jan 2022 17:18:45 +0800 Subject: soc/mediatek: Save dramc_param header to mrc_cache Fast-k flow may need to re-init header because mrc_cache doesn't store header. Storing header together with dparam data is better for data consistancy. TEST=fast calibration pass on Corsola BUG=b:204226005 Signed-off-by: Xi Chen Change-Id: I22982923dce06c9e770aa4f20f3dcd2f33685d84 Reviewed-on: https://review.coreboot.org/c/coreboot/+/61294 Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu --- src/soc/mediatek/common/memory.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/soc') diff --git a/src/soc/mediatek/common/memory.c b/src/soc/mediatek/common/memory.c index 93856d51e6..1b18dc7210 100644 --- a/src/soc/mediatek/common/memory.c +++ b/src/soc/mediatek/common/memory.c @@ -172,17 +172,15 @@ static void mem_init_set_default_config(struct dramc_param *dparam, static void mt_mem_init_run(struct dramc_param *dparam, const struct sdram_info *dram_info) { - const ssize_t mrc_cache_size = sizeof(dparam->dramc_datas); + const ssize_t mrc_cache_size = sizeof(*dparam); ssize_t data_size; struct stopwatch sw; int ret; /* Load calibration params from flash and run fast calibration */ - mem_init_set_default_config(dparam, dram_info); data_size = mrc_cache_load_current(MRC_TRAINING_DATA, DRAMC_PARAM_HEADER_VERSION, - &dparam->dramc_datas, - mrc_cache_size); + dparam, mrc_cache_size); if (data_size == mrc_cache_size) { printk(BIOS_INFO, "DRAM-K: Running fast calibration\n"); stopwatch_init(&sw); @@ -194,11 +192,10 @@ static void mt_mem_init_run(struct dramc_param *dparam, stopwatch_duration_msecs(&sw), ret); /* Erase flash data after fast calibration failed */ - memset(&dparam->dramc_datas, 0xa5, mrc_cache_size); + memset(dparam, 0xa5, mrc_cache_size); mrc_cache_stash_data(MRC_TRAINING_DATA, DRAMC_PARAM_HEADER_VERSION, - &dparam->dramc_datas, - mrc_cache_size); + dparam, mrc_cache_size); } else { printk(BIOS_INFO, "DRAM-K: Fast calibration passed in %ld msecs\n", stopwatch_duration_msecs(&sw)); @@ -220,7 +217,7 @@ static void mt_mem_init_run(struct dramc_param *dparam, stopwatch_duration_msecs(&sw)); mrc_cache_stash_data(MRC_TRAINING_DATA, DRAMC_PARAM_HEADER_VERSION, - &dparam->dramc_datas, mrc_cache_size); + dparam, mrc_cache_size); } else { printk(BIOS_ERR, "DRAM-K: Full calibration failed in %ld msecs\n", stopwatch_duration_msecs(&sw)); -- cgit v1.2.3