summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/mt8183/emi.c
diff options
context:
space:
mode:
authorYu-Ping Wu <yupingso@chromium.org>2019-10-07 15:55:57 +0800
committerPatrick Georgi <pgeorgi@google.com>2019-10-17 15:03:03 +0000
commitffb5ea3dc4b1189f39bdd4a2e288f0b973e759c1 (patch)
tree41c8036f56d2841e963d2df594365188ab7f73ec /src/soc/mediatek/mt8183/emi.c
parent7689a0f7921d49a8e8f68f7c054881b13a642450 (diff)
downloadcoreboot-ffb5ea3dc4b1189f39bdd4a2e288f0b973e759c1.tar.xz
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 <huayang.duan@mediatek.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/35481 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/mediatek/mt8183/emi.c')
-rw-r--r--src/soc/mediatek/mt8183/emi.c12
1 files changed, 8 insertions, 4 deletions
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;
}