mb/google/poppy: Allow use of optional secondary SPD
This change adds support for variants to use secondary SPD if required. This enables a variant to have different types of memory supported using the same image. BUG=b:73514687 Change-Id: I3add65ead99c510f2d6ec899fbf2cb9a06c79b0c Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/24972 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
39d3021b16
commit
908ea9132b
|
@ -110,19 +110,20 @@ static void mainboard_print_spd_info(const uint8_t *spd, enum memory_type type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintptr_t mainboard_get_spd_data(enum memory_type type)
|
static uintptr_t mainboard_get_spd_data(enum memory_type type, bool use_sec_spd)
|
||||||
{
|
{
|
||||||
char *spd_file;
|
char *spd_file;
|
||||||
size_t spd_file_len;
|
size_t spd_file_len;
|
||||||
int spd_index;
|
int spd_index;
|
||||||
const size_t spd_len = spd_info[type].len;
|
const size_t spd_len = spd_info[type].len;
|
||||||
|
const char *spd_bin = use_sec_spd ? "sec-spd.bin" : "spd.bin";
|
||||||
|
|
||||||
spd_index = variant_memory_sku();
|
spd_index = variant_memory_sku();
|
||||||
assert(spd_index >= 0);
|
assert(spd_index >= 0);
|
||||||
printk(BIOS_INFO, "SPD index %d\n", spd_index);
|
printk(BIOS_INFO, "SPD index %d\n", spd_index);
|
||||||
|
|
||||||
/* Load SPD data from CBFS */
|
/* Load SPD data from CBFS */
|
||||||
spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
|
spd_file = cbfs_boot_map_with_leak(spd_bin, CBFS_TYPE_SPD,
|
||||||
&spd_file_len);
|
&spd_file_len);
|
||||||
if (!spd_file)
|
if (!spd_file)
|
||||||
die("SPD data not found.");
|
die("SPD data not found.");
|
||||||
|
@ -160,7 +161,7 @@ void mainboard_memory_init_params(FSPM_UPD *mupd)
|
||||||
p.rcomp_resistor_size);
|
p.rcomp_resistor_size);
|
||||||
memcpy(&mem_cfg->RcompTarget, p.rcomp_target, p.rcomp_target_size);
|
memcpy(&mem_cfg->RcompTarget, p.rcomp_target, p.rcomp_target_size);
|
||||||
|
|
||||||
mem_cfg->MemorySpdPtr00 = mainboard_get_spd_data(p.type);
|
mem_cfg->MemorySpdPtr00 = mainboard_get_spd_data(p.type, p.use_sec_spd);
|
||||||
mem_cfg->MemorySpdPtr10 = mem_cfg->MemorySpdPtr00;
|
mem_cfg->MemorySpdPtr10 = mem_cfg->MemorySpdPtr00;
|
||||||
mem_cfg->MemorySpdDataLen = spd_info[p.type].len;
|
mem_cfg->MemorySpdDataLen = spd_info[p.type].len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,19 @@
|
||||||
|
|
||||||
SPD_BIN = $(obj)/spd.bin
|
SPD_BIN = $(obj)/spd.bin
|
||||||
|
SEC_SPD_BIN = $(obj)/sec-spd.bin
|
||||||
|
|
||||||
|
define gen_spd_bin
|
||||||
|
for f in $2; \
|
||||||
|
do for c in $$(cat $$f | grep -v ^#); \
|
||||||
|
do printf $$(printf '\%o' 0x$$c); \
|
||||||
|
done; \
|
||||||
|
done > $1
|
||||||
|
endef
|
||||||
|
|
||||||
|
add_spd_to_cbfs= \
|
||||||
|
$(eval cbfs-files-y += $1) \
|
||||||
|
$(eval $1-file := $2) \
|
||||||
|
$(eval $1-type := spd)
|
||||||
|
|
||||||
ifeq ($(SPD_SOURCES),)
|
ifeq ($(SPD_SOURCES),)
|
||||||
SPD_DEPS := $(error SPD_SOURCES is not set. Variant must provide this)
|
SPD_DEPS := $(error SPD_SOURCES is not set. Variant must provide this)
|
||||||
|
@ -7,14 +21,20 @@ else
|
||||||
SPD_DEPS := $(foreach f, $(SPD_SOURCES), src/mainboard/$(MAINBOARDDIR)/spd/$(f).spd.hex)
|
SPD_DEPS := $(foreach f, $(SPD_SOURCES), src/mainboard/$(MAINBOARDDIR)/spd/$(f).spd.hex)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Include spd ROM data
|
# Include SPD ROM data
|
||||||
$(SPD_BIN): $(SPD_DEPS)
|
$(SPD_BIN): $(SPD_DEPS)
|
||||||
for f in $+; \
|
$(call gen_spd_bin, $@, $+)
|
||||||
do for c in $$(cat $$f | grep -v ^#); \
|
|
||||||
do printf $$(printf '\%o' 0x$$c); \
|
|
||||||
done; \
|
|
||||||
done > $@
|
|
||||||
|
|
||||||
cbfs-files-y += spd.bin
|
$(call add_spd_to_cbfs, spd.bin, $(SPD_BIN))
|
||||||
spd.bin-file := $(SPD_BIN)
|
|
||||||
spd.bin-type := spd
|
# Add optional secondary SPD ROM data if present
|
||||||
|
ifneq ($(SEC_SPD_SOURCES),)
|
||||||
|
|
||||||
|
SEC_SPD_DEPS := $(foreach f, $(SEC_SPD_SOURCES), src/mainboard/$(MAINBOARDDIR)/spd/$(f).spd.hex)
|
||||||
|
|
||||||
|
$(SEC_SPD_BIN): $(SEC_SPD_DEPS)
|
||||||
|
$(call gen_spd_bin, $@, $+)
|
||||||
|
|
||||||
|
$(call add_spd_to_cbfs, sec-spd.bin, $(SEC_SPD_BIN))
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
|
@ -45,6 +45,7 @@ struct memory_params {
|
||||||
size_t rcomp_resistor_size;
|
size_t rcomp_resistor_size;
|
||||||
const void *rcomp_target;
|
const void *rcomp_target;
|
||||||
size_t rcomp_target_size;
|
size_t rcomp_target_size;
|
||||||
|
bool use_sec_spd;
|
||||||
};
|
};
|
||||||
|
|
||||||
void variant_memory_params(struct memory_params *p);
|
void variant_memory_params(struct memory_params *p);
|
||||||
|
|
Loading…
Reference in New Issue