soc/mediatek/common: Print DRAM calibration status as string

Logs such as "DRAM-K: calibration failed: status = 1" give little
information about the failure reason. Add get_status_string() and use it
to print the return status as a string.

Change-Id: If20282f0de7ba8ce884d0016fe8da1dc93a33ea4
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90484
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Chen-Tsung Hsieh <chentsung@google.com>
This commit is contained in:
Yu-Ping Wu 2025-12-12 12:22:06 +08:00 committed by Matt DeVillier
commit 9a3818f9b6
3 changed files with 27 additions and 3 deletions

View file

@ -11,6 +11,27 @@ struct dramc_param *get_dramc_param_from_blob(void *blob)
return (struct dramc_param *)blob;
}
static const char *const status_strings[] = {
[DRAMC_SUCCESS] = "success",
[DRAMC_ERR_INVALID_VERSION] = "invalid version",
[DRAMC_ERR_INVALID_SIZE] = "invalid size",
[DRAMC_ERR_INVALID_FLAGS] = "invalid flags",
[DRAMC_ERR_RECALIBRATE] = "full calibration needed",
[DRAMC_ERR_INIT_DRAM] = "calibration error",
[DRAMC_ERR_COMPLEX_RW_MEM_TEST] = "mem test failure",
[DRAMC_ERR_1ST_COMPLEX_RW_MEM_TEST] = "1st mem test failure",
[DRAMC_ERR_2ND_COMPLEX_RW_MEM_TEST] = "2nd mem test failure",
[DRAMC_ERR_FAST_CALIBRATION] = "fast calibration error",
};
const char *get_status_string(u16 status)
{
const char *s = NULL;
if (status < ARRAY_SIZE(status_strings))
s = status_strings[status];
return s ? s : "UNKNOWN STATUS";
}
void dump_param_header(const void *blob)
{
const struct dramc_param *dparam = blob;

View file

@ -105,6 +105,7 @@ struct ddr_base_info {
const struct sdram_info *get_sdram_config(void);
struct dramc_param *get_dramc_param_from_blob(void *blob);
const char *get_status_string(u16 status);
void dump_param_header(const void *blob);
int validate_dramc_param(const void *blob);
int is_valid_dramc_param(const void *blob);

View file

@ -172,9 +172,11 @@ static int run_dram_blob(struct dramc_param *dparam)
prog_set_entry(&dram, prog_entry(&dram), dparam);
prog_run(&dram);
if (dparam->header.status != DRAMC_SUCCESS) {
printk(BIOS_ERR, "DRAM-K: calibration failed: status = %d\n",
dparam->header.status);
u16 status = dparam->header.status;
if (status != DRAMC_SUCCESS) {
printk(BIOS_ERR, "DRAM-K: calibration failed: status = %d (%s)\n",
status, get_status_string(status));
return -3;
}