lib/spd: respect spd memory part name override
The BIOS log was looking in the spd data for the part name, but part names are stripped from generic SPDs. For these cases, a mainboard can override the dram part number string, so the spd logging code needs to check for an override string when logging the dram part number. Change print_spd_info() to use an override string if declared. BUG=b:168724473 TEST="emerge-volteer coreboot chromeos-bootimage", flash and boot volteer2 and verify that the BIOS log shows a part name when logging SPD information: SPD: module part number is K4U6E3S4AA-MGCL I also modified volteer to not override the part name and verified that this change did as expected and printed a blank string. Change-Id: I91971e07c450492dbb0588abd1c3c692ee0d3bb0 Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/45459 Reviewed-by: Furquan Shaikh <furquan@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
93d483db89
commit
88d4e82b33
|
@ -143,34 +143,41 @@ static int spd_get_busw(const uint8_t spd[], int dram_type)
|
||||||
return spd_busw[index];
|
return spd_busw[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spd_get_name(const uint8_t spd[], char spd_name[], int dram_type)
|
static void spd_get_name(const uint8_t spd[], int type, const char **spd_name, size_t *len)
|
||||||
{
|
{
|
||||||
switch (dram_type) {
|
*spd_name = mainboard_get_dram_part_num();
|
||||||
|
if (*spd_name != NULL) {
|
||||||
|
*len = strlen(*spd_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
case SPD_DRAM_DDR3:
|
case SPD_DRAM_DDR3:
|
||||||
memcpy(spd_name, &spd[DDR3_SPD_PART_OFF], DDR3_SPD_PART_LEN);
|
*spd_name = (const char *) &spd[DDR3_SPD_PART_OFF];
|
||||||
spd_name[DDR3_SPD_PART_LEN] = 0;
|
*len = DDR3_SPD_PART_LEN;
|
||||||
break;
|
break;
|
||||||
case SPD_DRAM_LPDDR3_INTEL:
|
case SPD_DRAM_LPDDR3_INTEL:
|
||||||
memcpy(spd_name, &spd[LPDDR3_SPD_PART_OFF],
|
*spd_name = (const char *) &spd[LPDDR3_SPD_PART_OFF];
|
||||||
LPDDR3_SPD_PART_LEN);
|
*len = LPDDR3_SPD_PART_LEN;
|
||||||
spd_name[LPDDR3_SPD_PART_LEN] = 0;
|
|
||||||
break;
|
break;
|
||||||
/* LPDDR3, LPDDR4 and DDR4 have the same part number offset */
|
/* LPDDR3, LPDDR4 and DDR4 have same part number offset and length */
|
||||||
case SPD_DRAM_LPDDR3_JEDEC:
|
case SPD_DRAM_LPDDR3_JEDEC:
|
||||||
case SPD_DRAM_DDR4:
|
case SPD_DRAM_DDR4:
|
||||||
case SPD_DRAM_LPDDR4:
|
case SPD_DRAM_LPDDR4:
|
||||||
case SPD_DRAM_LPDDR4X:
|
case SPD_DRAM_LPDDR4X:
|
||||||
memcpy(spd_name, &spd[DDR4_SPD_PART_OFF], DDR4_SPD_PART_LEN);
|
*spd_name = (const char *) &spd[DDR4_SPD_PART_OFF];
|
||||||
spd_name[DDR4_SPD_PART_LEN] = 0;
|
*len = DDR4_SPD_PART_LEN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
*len = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_spd_info(uint8_t spd[])
|
void print_spd_info(uint8_t spd[])
|
||||||
{
|
{
|
||||||
char spd_name[DDR4_SPD_PART_LEN + 1] = { 0 };
|
const char *nameptr = NULL;
|
||||||
|
size_t len;
|
||||||
int type = spd[SPD_DRAM_TYPE];
|
int type = spd[SPD_DRAM_TYPE];
|
||||||
int banks = spd_get_banks(spd, type);
|
int banks = spd_get_banks(spd, type);
|
||||||
int capmb = spd_get_capmb(spd);
|
int capmb = spd_get_capmb(spd);
|
||||||
|
@ -184,9 +191,9 @@ void print_spd_info(uint8_t spd[])
|
||||||
printk(BIOS_INFO, "SPD: module type is %s\n",
|
printk(BIOS_INFO, "SPD: module type is %s\n",
|
||||||
spd_get_module_type_string(type));
|
spd_get_module_type_string(type));
|
||||||
/* Module Part Number */
|
/* Module Part Number */
|
||||||
spd_get_name(spd, spd_name, type);
|
spd_get_name(spd, type, &nameptr, &len);
|
||||||
|
if (nameptr)
|
||||||
printk(BIOS_INFO, "SPD: module part number is %s\n", spd_name);
|
printk(BIOS_INFO, "SPD: module part number is %.*s\n", (int) len, nameptr);
|
||||||
|
|
||||||
printk(BIOS_INFO,
|
printk(BIOS_INFO,
|
||||||
"SPD: banks %d, ranks %d, rows %d, columns %d, density %d Mb\n",
|
"SPD: banks %d, ranks %d, rows %d, columns %d, density %d Mb\n",
|
||||||
|
|
Loading…
Reference in New Issue