summaryrefslogtreecommitdiffstats
path: root/src/soc/mediatek/mt8183/memory.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/memory.c
parent7689a0f7921d49a8e8f68f7c054881b13a642450 (diff)
downloadcoreboot-ffb5ea3dc4b1189f39bdd4a2e288f0b973e759c1.tar.gz
coreboot-ffb5ea3dc4b1189f39bdd4a2e288f0b973e759c1.tar.bz2
coreboot-ffb5ea3dc4b1189f39bdd4a2e288f0b973e759c1.zip
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/memory.c')
-rw-r--r--src/soc/mediatek/mt8183/memory.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/soc/mediatek/mt8183/memory.c b/src/soc/mediatek/mt8183/memory.c
index 19f732609fc5..bd5c74c6dcb8 100644
--- a/src/soc/mediatek/mt8183/memory.c
+++ b/src/soc/mediatek/mt8183/memory.c
@@ -19,10 +19,9 @@
#include <soc/dramc_param.h>
#include <soc/dramc_pi_api.h>
#include <soc/emi.h>
-#include <string.h>
#include <symbols.h>
-static void mt_mem_test(void)
+static int mt_mem_test(void)
{
u64 rank_size[RANK_MAX];
@@ -43,11 +42,16 @@ static void mt_mem_test(void)
printk(BIOS_DEBUG, "[MEM] complex R/W mem test %s : %d\n",
(i == 0) ? "pass" : "fail", i);
- ASSERT(i == 0);
+ if (i != 0) {
+ dramc_show("DRAM memory test failed\n");
+ return -1;
+ }
addr += rank_size[r];
}
}
+
+ return 0;
}
static void dump_param_header(const struct dramc_param *dparam)
@@ -147,9 +151,8 @@ void mt_mem_init(struct dramc_param_ops *dparam_ops)
if (dram_run_fast_calibration(dparam, config) == 0) {
printk(BIOS_INFO,
"DRAM calibraion params loaded from flash\n");
- mt_set_emi(dparam);
- mt_mem_test();
- return;
+ if (mt_set_emi(dparam) == 0 && mt_mem_test() == 0)
+ return;
}
} else {
printk(BIOS_WARNING,
@@ -174,6 +177,8 @@ void mt_mem_init(struct dramc_param_ops *dparam_ops)
/* Init params from sdram configs and run partial calibration */
init_sdram_params(dparam->freq_params, get_sdram_config());
- mt_set_emi(dparam);
- mt_mem_test();
+ if (mt_set_emi(dparam) != 0)
+ die("Set emi failed with params from sdram config\n");
+ if (mt_mem_test() != 0)
+ die("Memory test failed with params from sdram config\n");
}