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 <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/36089
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
Yu-Ping Wu 2019-10-16 18:29:50 +08:00 committed by Patrick Georgi
parent ad4bf675ec
commit 998a3cc0da
1 changed files with 25 additions and 8 deletions

View File

@ -17,6 +17,7 @@
#include <cbfs.h> #include <cbfs.h>
#include <console/console.h> #include <console/console.h>
#include <ip_checksum.h> #include <ip_checksum.h>
#include <security/vboot/vboot_common.h>
#include <soc/dramc_param.h> #include <soc/dramc_param.h>
#include <soc/dramc_pi_api.h> #include <soc/dramc_pi_api.h>
#include <soc/emi.h> #include <soc/emi.h>
@ -163,13 +164,21 @@ void mt_mem_init(struct dramc_param_ops *dparam_ops)
if (CONFIG(MT8183_DRAM_EMCP)) if (CONFIG(MT8183_DRAM_EMCP))
config |= DRAMC_CONFIG_EMCP; config |= DRAMC_CONFIG_EMCP;
const bool recovery_mode = vboot_recovery_mode_enabled();
/* Load calibration params from flash and run fast calibration */ /* 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) { if (dram_run_fast_calibration(dparam, config) == 0) {
printk(BIOS_INFO, 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) if (mt_set_emi(dparam) == 0 && mt_mem_test() == 0)
return; return;
} else {
printk(BIOS_ERR,
"Failed to apply cached calibration data\n");
} }
} else { } else {
printk(BIOS_WARNING, printk(BIOS_WARNING,
@ -177,16 +186,23 @@ void mt_mem_init(struct dramc_param_ops *dparam_ops)
} }
/* Run full calibration */ /* Run full calibration */
printk(BIOS_INFO, "DRAM-K: Full Calibration\n");
int err = dram_run_full_calibration(dparam, config); int err = dram_run_full_calibration(dparam, config);
if (err == 0) { if (err == 0) {
printk(BIOS_INFO, "Successfully loaded DRAM blobs and " printk(BIOS_INFO, "Successfully loaded DRAM blobs and "
"ran DRAM calibration\n"); "ran DRAM calibration\n");
/*
* 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); set_source_to_flash(dparam->freq_params);
dparam->header.checksum = compute_checksum(dparam); dparam->header.checksum = compute_checksum(dparam);
dparam_ops->write_to_flash(dparam); dparam_ops->write_to_flash(dparam);
printk(BIOS_DEBUG, "Calibration params saved to flash: " printk(BIOS_DEBUG, "Calibration params saved to flash: "
"version=%#x, size=%#x\n", "version=%#x, size=%#x\n",
dparam->header.version, dparam->header.size); dparam->header.version, dparam->header.size);
}
return; return;
} }
@ -194,6 +210,7 @@ void mt_mem_init(struct dramc_param_ops *dparam_ops)
"falling back to load default sdram param\n", err); "falling back to load default sdram param\n", err);
/* Init params from sdram configs and run partial calibration */ /* 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()); init_sdram_params(dparam->freq_params, get_sdram_config());
if (mt_set_emi(dparam) != 0) if (mt_set_emi(dparam) != 0)
die("Set emi failed with params from sdram config\n"); die("Set emi failed with params from sdram config\n");