xref: /aosp_15_r20/external/coreboot/src/mainboard/google/poppy/spd/Makefile.mk (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1## SPDX-License-Identifier: GPL-2.0-only
2
3SEC_SPD_BIN = $(obj)/sec-spd.bin
4
5define gen_spd_bin
6	for f in $2; \
7	  do for c in $$(cat $$f | grep -v ^#); \
8	    do printf $$(printf '\\%o' 0x$$c); \
9	  done; \
10	done > $1
11endef
12
13add_spd_to_cbfs= \
14	$(eval cbfs-files-y += $1) \
15	$(eval $1-file := $2) \
16	$(eval $1-type := spd)
17
18ifeq ($(SPD_SOURCES),)
19	SPD_DEPS := $(error SPD_SOURCES is not set. Variant must provide this)
20endif
21
22# Add optional secondary SPD ROM data if present
23ifneq ($(SEC_SPD_SOURCES),)
24
25SEC_SPD_DEPS := $(foreach f, $(SEC_SPD_SOURCES), src/mainboard/$(MAINBOARDDIR)/spd/$(f).spd.hex)
26
27$(SEC_SPD_BIN): $(SEC_SPD_DEPS)
28		$(call gen_spd_bin, $@, $+)
29
30$(call add_spd_to_cbfs, sec-spd.bin, $(SEC_SPD_BIN))
31
32endif
33