Yidi Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/46932 )
Change subject: mt8192/dpm.c: use load_blob_file to load the blob files ......................................................................
mt8192/dpm.c: use load_blob_file to load the blob files
Use load_blob_file to load the blob files.
TEST=1. emerge-asurada coreboot chromeos-bootimage; 2. See following log during booting. load_blob_file: Load dpm.dm in 15 msecs, size 36 bytes load_blob_file: Load dpm.pm in 18 msecs, size 13848 bytes 3. Test suspend/resume by: a. suspend (on DUT): echo mem > /sys/power/stat b. resume (on host): dut-control power_state:on
Signed-off-by: Yidi Lin yidi.lin@mediatek.com Change-Id: If5e51d1390a3daf5fac68e1180506ec0431160d2 --- M src/soc/mediatek/mt8192/dpm.c 1 file changed, 10 insertions(+), 36 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/32/46932/1
diff --git a/src/soc/mediatek/mt8192/dpm.c b/src/soc/mediatek/mt8192/dpm.c index ef46c30..912f153 100644 --- a/src/soc/mediatek/mt8192/dpm.c +++ b/src/soc/mediatek/mt8192/dpm.c @@ -1,50 +1,30 @@ /* SPDX-License-Identifier: GPL-2.0-only */
-#include <assert.h> -#include <cbfs.h> #include <console/console.h> -#include <delay.h> #include <device/mmio.h> #include <soc/dpm.h> +#include <soc/mtlib_common.h> #include <timer.h>
-#define DM_BUF_SIZE (2 * KiB) -#define PM_BUF_SIZE (20 * KiB) - -static u8 dpm_dm_bin[DM_BUF_SIZE] __aligned(8); -static u8 dpm_pm_bin[PM_BUF_SIZE] __aligned(8); -static void *dpm_pm_reg = (void *)DPM_PM_SRAM_BASE; -static void *dpm_dm_reg = (void *)DPM_DM_SRAM_BASE;
/* Return Value: 0 successful, < 0 means failed */ static int dpm_load_firmware(void) { const char *dm_file_name = "dpm.dm"; const char *pm_file_name = "dpm.pm"; - size_t dm_file_bytes, pm_file_bytes; - - dm_file_bytes = cbfs_boot_load_file(dm_file_name, dpm_dm_bin, - sizeof(dpm_dm_bin), CBFS_TYPE_RAW); - if (dm_file_bytes == 0) { - printk(BIOS_ERR, "binary %s not found\n", dm_file_name); - return -1; - } - - pm_file_bytes = cbfs_boot_load_file(pm_file_name, dpm_pm_bin, - sizeof(dpm_pm_bin), CBFS_TYPE_RAW); - if (pm_file_bytes == 0) { - printk(BIOS_ERR, "binary %s not found\n", pm_file_name); - return -2; - } - printk(BIOS_INFO, "dm_file_bytes: %d, pm_file_bytes: %d\n", - (int)dm_file_bytes, (int)pm_file_bytes);
/* config DPM SRAM layout */ write32(&mtk_dpm->sw_rstn, read32(&mtk_dpm->sw_rstn) | 0x10000000);
- /* copy PM DM to DPM_SRAM */ - memcpy(dpm_pm_reg, dpm_pm_bin, pm_file_bytes); - memcpy(dpm_dm_reg, dpm_dm_bin, dm_file_bytes); + if (load_blob_file(dm_file_name, DPM_DM_SRAM_BASE)) { + printk(BIOS_ERR, "binary %s not found\n", dm_file_name); + return -1; + } + + if (load_blob_file(pm_file_name, DPM_PM_SRAM_BASE)) { + printk(BIOS_ERR, "binary %s not found\n", pm_file_name); + return -2; + }
/* write bootargs */ write32(&mtk_dpm->twam_window_len, 0x0); @@ -58,16 +38,10 @@
int dpm_init(void) { - struct stopwatch sw; - stopwatch_init(&sw); - if (dpm_load_firmware()) { printk(BIOS_ERR, "DPM: firmware is not ready\n"); return -1; }
- printk(BIOS_INFO, "DPM: load finish in %ld msecs\n", - stopwatch_duration_msecs(&sw)); - return 0; }