From 998a3cc0dab5e73ae2a169aeb04df6b4db4f968a Mon Sep 17 00:00:00 2001 From: Yu-Ping Wu Date: Wed, 16 Oct 2019 18:29:50 +0800 Subject: soc/mediatek/mt8183: Skip fast calibration in recovery mode SoC DRAM team suggested always running full calibration mode in recovery mode because it is possible to get unstable memory even if the complex memory test has been passed. Since the recovery mode runs from RO and we only have training data cache for RW, the trained calibration data can't be saved since RO and RW may be running different firmware. Also revised few message to make it more clear for what calibration mode (fast, full, or partial) has been executed. BRANCH=kukui BUG=b:139099592 TEST=emerge-kukui coreboot Change-Id: I29e0df71dc3357462e15ce8fc2ba02f21b54ed33 Signed-off-by: Yu-Ping Wu Reviewed-on: https://review.coreboot.org/c/coreboot/+/36089 Tested-by: build bot (Jenkins) Reviewed-by: Hung-Te Lin --- src/soc/mediatek/mt8183/memory.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'src/soc/mediatek/mt8183') diff --git a/src/soc/mediatek/mt8183/memory.c b/src/soc/mediatek/mt8183/memory.c index b657708193..2e6391339c 100644 --- a/src/soc/mediatek/mt8183/memory.c +++ b/src/soc/mediatek/mt8183/memory.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -163,13 +164,21 @@ void mt_mem_init(struct dramc_param_ops *dparam_ops) if (CONFIG(MT8183_DRAM_EMCP)) config |= DRAMC_CONFIG_EMCP; + const bool recovery_mode = vboot_recovery_mode_enabled(); + /* Load calibration params from flash and run fast calibration */ - if (dparam_ops->read_from_flash(dparam)) { + if (recovery_mode) { + printk(BIOS_WARNING, "Skip loading cached calibration data\n"); + } else if (dparam_ops->read_from_flash(dparam)) { + printk(BIOS_INFO, "DRAM-K: Fast Calibration\n"); if (dram_run_fast_calibration(dparam, config) == 0) { printk(BIOS_INFO, - "DRAM calibraion params loaded from flash\n"); + "Calibration params loaded from flash\n"); if (mt_set_emi(dparam) == 0 && mt_mem_test() == 0) return; + } else { + printk(BIOS_ERR, + "Failed to apply cached calibration data\n"); } } else { printk(BIOS_WARNING, @@ -177,16 +186,23 @@ void mt_mem_init(struct dramc_param_ops *dparam_ops) } /* Run full calibration */ + printk(BIOS_INFO, "DRAM-K: Full Calibration\n"); int err = dram_run_full_calibration(dparam, config); if (err == 0) { printk(BIOS_INFO, "Successfully loaded DRAM blobs and " "ran DRAM calibration\n"); - set_source_to_flash(dparam->freq_params); - dparam->header.checksum = compute_checksum(dparam); - dparam_ops->write_to_flash(dparam); - printk(BIOS_DEBUG, "Calibration params saved to flash: " - "version=%#x, size=%#x\n", - dparam->header.version, dparam->header.size); + /* + * In recovery mode the system boots in RO but the flash params + * should be calibrated for RW so we can't mix them up. + */ + if (!recovery_mode) { + set_source_to_flash(dparam->freq_params); + dparam->header.checksum = compute_checksum(dparam); + dparam_ops->write_to_flash(dparam); + printk(BIOS_DEBUG, "Calibration params saved to flash: " + "version=%#x, size=%#x\n", + dparam->header.version, dparam->header.size); + } return; } @@ -194,6 +210,7 @@ void mt_mem_init(struct dramc_param_ops *dparam_ops) "falling back to load default sdram param\n", err); /* Init params from sdram configs and run partial calibration */ + printk(BIOS_INFO, "DRAM-K: Partial Calibration\n"); init_sdram_params(dparam->freq_params, get_sdram_config()); if (mt_set_emi(dparam) != 0) die("Set emi failed with params from sdram config\n"); -- cgit v1.2.3