Yidi Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/46930 )
Change subject: soc/mediatek/common: A common API for loading the blob file ......................................................................
soc/mediatek/common: A common API for loading the blob file
load_blob_file is added for loading the blog file to the specified memory address. This function also measures the load time and the blob size.
Signed-off-by: Yidi Lin yidi.lin@mediatek.com Change-Id: Ie94001bbda25fe015f43172e92a1006e059de223 --- A src/soc/mediatek/common/include/soc/mtlib_common.h A src/soc/mediatek/common/mtlib.c M src/soc/mediatek/mt8192/Makefile.inc 3 files changed, 38 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/30/46930/1
diff --git a/src/soc/mediatek/common/include/soc/mtlib_common.h b/src/soc/mediatek/common/include/soc/mtlib_common.h new file mode 100644 index 0000000..3210468 --- /dev/null +++ b/src/soc/mediatek/common/include/soc/mtlib_common.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef SOC_MEDIATEK_MTLIB_COMMON_H +#define SOC_MEDIATEK_MTLIB_COMMON_H + +int load_blob_file(const char *name, unsigned long addr); + +#endif /* SOC_MEDIATEK_MTLIB_COMMON_H */ diff --git a/src/soc/mediatek/common/mtlib.c b/src/soc/mediatek/common/mtlib.c new file mode 100644 index 0000000..cdb748b --- /dev/null +++ b/src/soc/mediatek/common/mtlib.c @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <cbfs.h> +#include <console/console.h> +#include <soc/mtlib_common.h> +#include <timer.h> + +#define BUF_SIZE (128 * KiB) +static u8 blob_data[BUF_SIZE] __aligned(8); + +int load_blob_file(const char *name, unsigned long addr) +{ + struct stopwatch sw; + size_t blob_bytes; + + stopwatch_init(&sw); + + blob_bytes = cbfs_boot_load_file(name, blob_data, sizeof(blob_data), CBFS_TYPE_RAW); + if (blob_bytes == 0) { + printk(BIOS_ERR, "binary %s not found\n", name); + return CB_ERR; + } + + memcpy((void *)addr, blob_data, blob_bytes); + printk(BIOS_DEBUG, "%s: Load %s in %ld msecs, size %ld bytes\n", + __func__, name, stopwatch_duration_msecs(&sw), blob_bytes); + + return CB_SUCCESS; +} diff --git a/src/soc/mediatek/mt8192/Makefile.inc b/src/soc/mediatek/mt8192/Makefile.inc index 6890910..bebb0c4 100755 --- a/src/soc/mediatek/mt8192/Makefile.inc +++ b/src/soc/mediatek/mt8192/Makefile.inc @@ -52,6 +52,7 @@ ramstage-y += devapc.c ramstage-y += ufs.c ramstage-y += mcupm.c +ramstage-y += ../common/mtlib.c ramstage-y += ../common/timer.c ramstage-y += ../common/uart.c ramstage-y += ../common/usb.c usb.c