From 9a30c7289fd0d95655e368100ed444848d46e85d Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Tue, 7 Aug 2018 12:04:21 -0600 Subject: soc/intel/apollolake: add new dimm info saving API The current call for saving dimm info passed the lpddr4_cfg and memory sku id. In order to prepare decoupling the part number from lpddr4_cfg provide a new API, save_lpddr4_dimm_info_part_num(), which explicitly takes the part number. The previous API now uses the new one internally. BUG=b:112203105 Change-Id: Ieadf452b6daa3231a0c5e3be61b0603b40d0fff2 Signed-off-by: Aaron Durbin Reviewed-on: https://review.coreboot.org/27944 Tested-by: build bot (Jenkins) Reviewed-by: Justin TerAvest Reviewed-by: Furquan Shaikh --- src/soc/intel/apollolake/include/soc/meminit.h | 4 ++++ src/soc/intel/apollolake/meminit_util_apl.c | 27 +++++++++++++++++-------- src/soc/intel/apollolake/meminit_util_glk.c | 28 ++++++++++++++++++-------- 3 files changed, 43 insertions(+), 16 deletions(-) (limited to 'src/soc/intel') diff --git a/src/soc/intel/apollolake/include/soc/meminit.h b/src/soc/intel/apollolake/include/soc/meminit.h index 31645a4dc4..d75a4873b0 100644 --- a/src/soc/intel/apollolake/include/soc/meminit.h +++ b/src/soc/intel/apollolake/include/soc/meminit.h @@ -131,7 +131,11 @@ struct lpddr4_cfg { */ void meminit_lpddr4_by_sku(FSP_M_CONFIG *cfg, const struct lpddr4_cfg *lpcfg, size_t sku_id); +/* One of the two below needs to be called. If one is obtaining the part + * number out of band from the lpddr_cfg then the part_num variant will + * suffice. */ void save_lpddr4_dimm_info(const struct lpddr4_cfg *lpcfg, size_t mem_sku); +void save_lpddr4_dimm_info_part_num(const char *dram_part_num); /* Retrieve the amount of memory configured in the system in MiB. It's only * valid during romstage. */ diff --git a/src/soc/intel/apollolake/meminit_util_apl.c b/src/soc/intel/apollolake/meminit_util_apl.c index f09f45beb8..755d708abe 100644 --- a/src/soc/intel/apollolake/meminit_util_apl.c +++ b/src/soc/intel/apollolake/meminit_util_apl.c @@ -27,7 +27,7 @@ 0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89 \ } -void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku) +void save_lpddr4_dimm_info_part_num(const char *dram_part_num) { int channel, dimm, dimm_max, index; size_t hob_size; @@ -39,11 +39,8 @@ void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku) const uint8_t smbios_memory_info_guid[16] = FSP_SMBIOS_MEMORY_INFO_GUID; - if (mem_sku >= lp4cfg->num_skus) { - printk(BIOS_ERR, "Too few LPDDR4 SKUs: 0x%zx/0x%zx\n", - mem_sku, lp4cfg->num_skus); - return; - } + if (!dram_part_num) + dram_part_num = "Unknown"; /* Locate the memory info HOB */ memory_info_hob = fsp_find_extension_hob_by_guid( @@ -90,8 +87,8 @@ void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku) memory_info_hob->MemoryFrequencyInMHz, channel_info->ChannelId, src_dimm->DimmId, - lp4cfg->skus[mem_sku].part_num, - strlen(lp4cfg->skus[mem_sku].part_num), + dram_part_num, + strlen(dram_part_num), memory_info_hob->DataWidth); index++; } @@ -99,3 +96,17 @@ void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku) mem_info->dimm_cnt = index; printk(BIOS_DEBUG, "%d DIMMs found\n", mem_info->dimm_cnt); } + +void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku) +{ + const char *part_num = NULL; + + if (mem_sku >= lp4cfg->num_skus) { + printk(BIOS_ERR, "Too few LPDDR4 SKUs: 0x%zx/0x%zx\n", + mem_sku, lp4cfg->num_skus); + } else { + part_num = lp4cfg->skus[mem_sku].part_num; + } + + save_lpddr4_dimm_info_part_num(part_num); +} diff --git a/src/soc/intel/apollolake/meminit_util_glk.c b/src/soc/intel/apollolake/meminit_util_glk.c index 21b09af89b..db69f5184b 100644 --- a/src/soc/intel/apollolake/meminit_util_glk.c +++ b/src/soc/intel/apollolake/meminit_util_glk.c @@ -27,7 +27,7 @@ 0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89 \ } -void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku) +void save_lpddr4_dimm_info_part_num(const char *dram_part_num) { int channel, dimm, dimm_max, index, node; size_t hob_size; @@ -40,11 +40,9 @@ void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku) const uint8_t smbios_memory_info_guid[16] = FSP_SMBIOS_MEMORY_INFO_GUID; - if (mem_sku >= lp4cfg->num_skus) { - printk(BIOS_ERR, "Too few LPDDR4 SKUs: 0x%zx/0x%zx\n", - mem_sku, lp4cfg->num_skus); - return; - } + if (!dram_part_num) + dram_part_num = "Unknown"; + /* Locate the memory info HOB */ memory_info_hob = fsp_find_extension_hob_by_guid( smbios_memory_info_guid, @@ -95,8 +93,8 @@ void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku) memory_info_hob->ConfiguredMemoryClockSpeed, channel_info->ChannelId, src_dimm->DimmId, - lp4cfg->skus[mem_sku].part_num, - strlen(lp4cfg->skus[mem_sku].part_num), + dram_part_num, + strlen(dram_part_num), memory_info_hob->DataWidth); index++; } @@ -105,3 +103,17 @@ void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku) mem_info->dimm_cnt = index; printk(BIOS_DEBUG, "%d DIMMs found\n", mem_info->dimm_cnt); } + +void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku) +{ + const char *part_num = NULL; + + if (mem_sku >= lp4cfg->num_skus) { + printk(BIOS_ERR, "Too few LPDDR4 SKUs: 0x%zx/0x%zx\n", + mem_sku, lp4cfg->num_skus); + } else { + part_num = lp4cfg->skus[mem_sku].part_num; + } + + save_lpddr4_dimm_info_part_num(part_num); +} -- cgit v1.2.3