From ffb5ea3dc4b1189f39bdd4a2e288f0b973e759c1 Mon Sep 17 00:00:00 2001 From: Yu-Ping Wu Date: Mon, 7 Oct 2019 15:55:57 +0800 Subject: soc/mediatek/mt8183: Handle memory test failure If DRAM calibration fails or mem test fails using the cached calibration results stored in flash, rerun DRAM full calibration. If partial calibration fails or the mem test following it fails, hang forever. Partial calibration acts as a fallback approach in case of full calibration failure. Therefore, if it fails, there would be no other ways to initialize DRAM. Instead of falling into reboot loop and draining out of battery, it is better to just hang so that the end user may notice that and send to RMA. BUG=b:80501386,b:139099592 BRANCH=kukui TEST=Boots correctly on Kukui Change-Id: I8e1d4f5bc7b45f45a8bfef74e86ec0ff6a556af4 Signed-off-by: Huayang Duan Reviewed-on: https://review.coreboot.org/c/coreboot/+/35481 Reviewed-by: Hung-Te Lin Reviewed-by: Paul Menzel Tested-by: build bot (Jenkins) --- src/soc/mediatek/mt8183/emi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/soc/mediatek/mt8183/emi.c') diff --git a/src/soc/mediatek/mt8183/emi.c b/src/soc/mediatek/mt8183/emi.c index 52baeb1688..4b08a10c08 100644 --- a/src/soc/mediatek/mt8183/emi.c +++ b/src/soc/mediatek/mt8183/emi.c @@ -342,12 +342,14 @@ void enable_emi_dcm(void) clrbits_le32(&ch[chn].emi.chn_conb, 0xff << 24); } -static void do_calib(const struct sdram_params *params, u8 freq_group) +static int do_calib(const struct sdram_params *params, u8 freq_group) { dramc_show("Start K, current clock is:%d\n", params->frequency); - dramc_calibrate_all_channels(params, freq_group); + if (dramc_calibrate_all_channels(params, freq_group) != 0) + return -1; dramc_ac_timing_optimize(freq_group); dramc_show("K finish with clock:%d\n", params->frequency); + return 0; } static void after_calib(void) @@ -356,7 +358,7 @@ static void after_calib(void) dramc_runtime_config(); } -void mt_set_emi(const struct dramc_param *dparam) +int mt_set_emi(const struct dramc_param *dparam) { const u8 *freq_tbl; const int shuffle = DRAM_DFS_SHUFFLE_1; @@ -372,7 +374,9 @@ void mt_set_emi(const struct dramc_param *dparam) params = &dparam->freq_params[shuffle]; init_dram(params, current_freqsel); - do_calib(params, current_freqsel); + if (do_calib(params, current_freqsel) != 0) + return -1; after_calib(); + return 0; } -- cgit v1.2.3