soc/qualcomm/common: Fix mem_chip_info bugs in QcLib glue

This patch fixes an issue introduced by CB:59195 when QcLib
doesn't return a mem_chip_info structure to coreboot, and
solves some other minor leftover issues from that patch.

BUG=b:182963902,b:177917361
TEST=Validated on qualcomm sc7280 development board

Signed-off-by: Ravi Kumar Bokka <rbokka@codeaurora.org>
Change-Id: I0d59669adaf287d0eb7b58ccb0fe3f98e3d23281
Reviewed-on: https://review.coreboot.org/c/coreboot/+/63026
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Ravi Kumar Bokka 2022-04-06 07:35:53 +05:30 committed by Julius Werner
parent b3a042f619
commit 4f9cb426be
1 changed files with 17 additions and 9 deletions

View File

@ -24,22 +24,31 @@ static void *mem_chip_addr;
static void write_mem_chip_information(struct qclib_cb_if_table_entry *te) static void write_mem_chip_information(struct qclib_cb_if_table_entry *te)
{ {
/* Save mem_chip_info in local variables ahead of hook running */ if (te->size > sizeof(struct mem_chip_info) &&
mem_chip_addr = (void *)te->blob_address; te->size == mem_chip_info_size((void *)te->blob_address)) {
/* Save mem_chip_addr in global variable ahead of hook running */
mem_chip_addr = (void *)te->blob_address;
}
} }
static void add_mem_chip_info(int unused) static void add_mem_chip_info(int unused)
{ {
void *mem_region_base = NULL; void *mem_region_base = NULL;
size_t size;
if (!mem_chip_addr) {
printk(BIOS_ERR, "Did not receive valid mem_chip_info from QcLib!");
return;
}
size = mem_chip_info_size(mem_chip_addr);
/* Add cbmem table */ /* Add cbmem table */
if (sizeof(struct mem_chip_info) != 0) mem_region_base = cbmem_add(CBMEM_ID_MEM_CHIP_INFO, size);
mem_region_base = cbmem_add(CBMEM_ID_MEM_CHIP_INFO,
sizeof(struct mem_chip_info));
ASSERT(mem_region_base != NULL); ASSERT(mem_region_base != NULL);
/* Migrate the data into CBMEM */ /* Migrate the data into CBMEM */
memcpy(mem_region_base, mem_chip_addr, sizeof(struct mem_chip_info)); memcpy(mem_region_base, mem_chip_addr, size);
} }
ROMSTAGE_CBMEM_INIT_HOOK(add_mem_chip_info); ROMSTAGE_CBMEM_INIT_HOOK(add_mem_chip_info);
@ -168,9 +177,8 @@ void qclib_load_and_run(void)
qclib_add_if_table_entry(QCLIB_TE_DDR_TRAINING_DATA, qclib_add_if_table_entry(QCLIB_TE_DDR_TRAINING_DATA,
_ddr_training, REGION_SIZE(ddr_training), 0); _ddr_training, REGION_SIZE(ddr_training), 0);
/* Attempt to read MEM CHIP information */ /* Address and size of this entry will be filled in by QcLib. */
qclib_add_if_table_entry(QCLIB_TE_MEM_CHIP_INFO, qclib_add_if_table_entry(QCLIB_TE_MEM_CHIP_INFO, NULL, 0, 0);
mem_chip_addr, sizeof(mem_chip_addr), 0);
/* Attempt to load PMICCFG Blob */ /* Attempt to load PMICCFG Blob */
data_size = cbfs_load(CONFIG_CBFS_PREFIX "/pmiccfg", data_size = cbfs_load(CONFIG_CBFS_PREFIX "/pmiccfg",