summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/.gitignore3
-rw-r--r--firmware/Kconfig91
-rw-r--r--firmware/Makefile140
3 files changed, 187 insertions, 47 deletions
diff --git a/firmware/.gitignore b/firmware/.gitignore
index a8a0dcec44..8f9a956eb6 100644
--- a/firmware/.gitignore
+++ b/firmware/.gitignore
@@ -1 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
*.bin
+*.bin-optee
diff --git a/firmware/Kconfig b/firmware/Kconfig
index 169c6ee915..ae7bbdc71e 100644
--- a/firmware/Kconfig
+++ b/firmware/Kconfig
@@ -1,16 +1,101 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
menu "Firmware files"
config EXTRA_FIRMWARE_DIR
string "Firmware blobs root directory"
default "firmware"
+config MISSING_FIRMWARE_ERROR
+ bool "Fail the build when required firmware is missing"
+ default y
+ help
+ In-tree Defconfigs that enable multiple boards with different firmware
+ binary requirements would say y here, so you don't need unrelated firmware
+ for the build to succeed.
+
+ Defconfigs custom-tailored to products would say n here as all boards
+ being built should be functional and have their firmware available.
+
+ If in doubt, say Y and refer to the documentation on where to acquire the
+ needed firmware.
+
config FIRMWARE_IMX_LPDDR4_PMU_TRAIN
- bool
+ bool
+
+config FIRMWARE_IMX_DDR4_PMU_TRAIN
+ bool
config FIRMWARE_IMX8MM_ATF
- bool
+ bool
+
+config FIRMWARE_IMX8MN_ATF
+ bool
+
+config FIRMWARE_IMX8MP_ATF
+ bool
config FIRMWARE_IMX8MQ_ATF
- bool
+ bool
+
+config FIRMWARE_IMX93_ATF
+ bool
+
+config FIRMWARE_IMX8MM_OPTEE
+ bool "install OP-TEE on i.MX8MM boards"
+ depends on FIRMWARE_IMX8MM_ATF && PBL_OPTEE
+ help
+ This enables OP-TEE loading and starting on i.MX8MM. Place the OP-TEE binary
+ in CONFIG_EXTRA_FIRMWARE_DIR/imx8mm-bl32.bin. When this option is enabled then
+ the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mm-bl31.bin-optee.
+
+config FIRMWARE_IMX8MN_OPTEE
+ bool "install OP-TEE on i.MX8MN boards"
+ depends on FIRMWARE_IMX8MN_ATF && PBL_OPTEE
+ help
+ This enables OP-TEE loading and starting on i.MX8MN. Place the OP-TEE binary
+ in CONFIG_EXTRA_FIRMWARE_DIR/imx8mn-bl32.bin. When this option is enabled then
+ the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mn-bl31.bin-optee.
+
+config FIRMWARE_IMX8MP_OPTEE
+ bool "install OP-TEE on i.MX8MP boards"
+ depends on FIRMWARE_IMX8MP_ATF && PBL_OPTEE
+ help
+ This enables OP-TEE loading and starting on i.MX8MP. Place the OP-TEE binary
+ in CONFIG_EXTRA_FIRMWARE_DIR/imx8mp-bl32.bin. When this option is enabled then
+ the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mp-bl31.bin-optee.
+
+config FIRMWARE_IMX8MQ_OPTEE
+ bool "install OP-TEE on i.MX8MQ boards"
+ depends on FIRMWARE_IMX8MQ_ATF && PBL_OPTEE
+ help
+ This enables OP-TEE loading and starting on i.MX8MQ. Place the OP-TEE binary
+ in CONFIG_EXTRA_FIRMWARE_DIR/imx8mq-bl32.bin. When this option is enabled then
+ the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mq-bl31.bin-optee.
+
+config FIRMWARE_IMX93_OPTEE
+ bool "install OP-TEE on i.MX93 boards"
+ depends on FIRMWARE_IMX93_ATF && PBL_OPTEE
+ help
+ This enables OP-TEE loading and starting on i.MX93. Place the OP-TEE binary
+ in CONFIG_EXTRA_FIRMWARE_DIR/imx93-bl32.bin. When this option is enabled then
+ the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx93-bl31.bin-optee.
+ Additionally OP-TEE requires a RAM firmware loaded into the ELE. This is expected
+ in CONFIG_EXTRA_FIRMWARE_DIR/mx93a0-ahab-container.img and
+ CONFIG_EXTRA_FIRMWARE_DIR/mx93a1-ahab-container.img. You can obtain it from
+ https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-ele-imx-0.1.0.bin
+
+config FIRMWARE_TQMA6UL_OPTEE
+ bool
+ depends on MACH_TQMA6UL && PBL_OPTEE
+ default y
+
+config FIRMWARE_CCBV2_OPTEE
+ bool
+ depends on MACH_WEBASTO_CCBV2 && PBL_OPTEE
+ default y
+
+config FIRMWARE_LS1028A_ATF
+ bool
endmenu
diff --git a/firmware/Makefile b/firmware/Makefile
index 3f2c31868a..83ce77f510 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -1,69 +1,121 @@
# SPDX-License-Identifier: GPL-2.0
-#
-# kbuild file for firmware/
-#
-firmware-$(CONFIG_FIRMWARE_IMX_LPDDR4_PMU_TRAIN) += \
+pbl-firmware-$(CONFIG_FIRMWARE_IMX_LPDDR4_PMU_TRAIN) += \
lpddr4_pmu_train_1d_dmem.bin \
lpddr4_pmu_train_1d_imem.bin \
lpddr4_pmu_train_2d_dmem.bin \
lpddr4_pmu_train_2d_imem.bin
-firmware-$(CONFIG_FIRMWARE_IMX8MM_ATF) += imx8mm-bl31.bin
-firmware-$(CONFIG_FIRMWARE_IMX8MQ_ATF) += imx8mq-bl31.bin
+pbl-firmware-$(CONFIG_FIRMWARE_IMX_DDR4_PMU_TRAIN) += \
+ ddr4_dmem_1d.bin \
+ ddr4_dmem_2d.bin \
+ ddr4_imem_1d.bin \
+ ddr4_imem_2d.bin
+pbl-firmware-$(CONFIG_FIRMWARE_IMX8MM_ATF) += imx8mm-bl31.bin$(if $(CONFIG_FIRMWARE_IMX8MM_OPTEE),-optee,)
+pbl-firmware-$(CONFIG_FIRMWARE_IMX8MN_ATF) += imx8mn-bl31.bin$(if $(CONFIG_FIRMWARE_IMX8MN_OPTEE),-optee,)
+pbl-firmware-$(CONFIG_FIRMWARE_IMX8MP_ATF) += imx8mp-bl31.bin$(if $(CONFIG_FIRMWARE_IMX8MP_OPTEE),-optee,)
+pbl-firmware-$(CONFIG_FIRMWARE_IMX8MQ_ATF) += imx8mq-bl31.bin
+pbl-firmware-$(CONFIG_FIRMWARE_IMX93_ATF) += imx93-bl31.bin$(if $(CONFIG_FIRMWARE_IMX93_OPTEE),-optee,)
+fw-external-$(CONFIG_FIRMWARE_IMX8MM_OPTEE) += imx8mm-bl32.bin
+fw-external-$(CONFIG_FIRMWARE_IMX8MN_OPTEE) += imx8mn-bl32.bin
+fw-external-$(CONFIG_FIRMWARE_IMX8MP_OPTEE) += imx8mp-bl32.bin
+fw-external-$(CONFIG_FIRMWARE_IMX93_OPTEE) += imx93-bl32.bin \
+ mx93a0-ahab-container.img \
+ mx93a1-ahab-container.img
+pbl-firmware-$(CONFIG_ARCH_RK3568) += rk3568-bl31.bin
+pbl-firmware-$(CONFIG_ARCH_RK3568_OPTEE) += rk3568-op-tee.bin
+pbl-firmware-$(CONFIG_ARCH_RK3588) += rk3588-bl31.bin
+pbl-firmware-$(CONFIG_ARCH_RK3588_OPTEE) += rk3588-op-tee.bin
+pbl-firmware-$(CONFIG_ARCH_RK3399) += rk3399-bl31.bin
+pbl-firmware-$(CONFIG_ARCH_RK3399_OPTEE) += rk3399-op-tee.bin
firmware-$(CONFIG_DRIVER_NET_FSL_FMAN) += fsl_fman_ucode_ls1046_r1.0_106_4_18.bin
firmware-$(CONFIG_ARCH_LAYERSCAPE_PPA) += ppa-ls1046a.bin
+fw-external-$(CONFIG_FIRMWARE_LS1028A_ATF) += ls1028a-bl31.bin
-# Create $(fwabs) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a
+pbl-firmware-$(CONFIG_FIRMWARE_CCBV2_OPTEE) += ccbv2_optee.bin
+pbl-firmware-$(CONFIG_FIRMWARE_TQMA6UL_OPTEE) += mba6ul_optee.bin
+
+# Create $(fwdir) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a
# leading /, it's relative to $(srctree).
fwdir := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE_DIR))
-fwabs := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir))
-
-fw-external-y := $(firmware-y)
-
-quiet_cmd_fwbin = MK_FW $@
- cmd_fwbin = FWNAME="$(patsubst firmware/%.gen.S,%,$@)"; \
- FWSTR="$(subst /,_,$(subst .,_,$(subst -,_,$(patsubst \
- firmware/%.gen.S,%,$@))))"; \
- ASM_WORD=$(if $(CONFIG_64BIT),.quad,.long); \
- ASM_ALIGN=$(if $(CONFIG_64BIT),3,2); \
- PROGBITS=$(if $(CONFIG_ARM),%,@)progbits; \
- echo "/* Generated by firmware/Makefile */" > $@;\
- echo " .section .rodata.$${FWSTR}" >>$@;\
- echo " .p2align $${ASM_ALIGN}" >>$@;\
- echo ".global _fw_$${FWSTR}_start" >>$@;\
- echo "_fw_$${FWSTR}_start:" >>$@;\
- echo " .incbin \"$(2)\"" >>$@;\
- echo ".global _fw_$${FWSTR}_end" >>$@;\
- echo "_fw_$${FWSTR}_end:" >>$@;
-
-# One of these files will change, or come into existence, whenever
-# the configuration changes between 32-bit and 64-bit. The .S files
-# need to change when that happens.
-wordsize_deps := $(wildcard include/config/64bit.h include/config/32bit.h)
-
-$(patsubst %,$(obj)/%.gen.S, $(fw-external-y)): %: $(wordsize_deps) \
- include/config/extra/firmware/dir.h
- $(call cmd,fwbin,$(fwabs)/$(patsubst $(obj)/%.gen.S,%,$@))
+fwdir := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir))
+fwobjdir := $(objtree)/firmware
+
+pbl-y := $(addsuffix .gen.o, $(pbl-firmware-y))
+obj-pbl-y := $(addsuffix .gen.o, $(firmware-y))
+pbl-fwext-y := $(addsuffix .extgen.o, $(fw-external-y))
+
+FWNAME = $(patsubst $(obj)/%.extgen.S,%,$(patsubst $(obj)/%.gen.S,%,$@))
+FWSTR = $(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME))))
+FWNAME_EXISTS = $(if $(wildcard $(fwdir)/$(FWNAME)),1,0)
+
+filechk_fwbin = { \
+ echo "/* Generated by $(src)/Makefile */" ;\
+ echo "\#include <asm-generic/pointer.h>" ;\
+ echo ".section .note.GNU-stack,\"\",%progbits" ;\
+ echo " .section $2,\"$3\"" ;\
+ echo " .p2align ASM_LGPTR" ;\
+ echo ".global _fw_$(FWSTR)_start" ;\
+ echo "_fw_$(FWSTR)_start:" ;\
+ echo "\#if $(FWNAME_EXISTS)" ;\
+ echo " .incbin \"$(fwdir)/$(FWNAME)\"" ;\
+ echo "\#else" ;\
+ echo "ASM_PTR _fwname_$(FWSTR)" ;\
+ echo "\#endif" ;\
+ echo ".global _fw_$(FWSTR)_end" ;\
+ echo "_fw_$(FWSTR)_end:" ;\
+ echo "\#ifdef __PBL__" ;\
+ echo " .section .missing_fw,\"a\"" ;\
+ echo "_fwname_$(FWSTR):" ;\
+ printf '.ascii "%s"\n' 'firmware/$(FWNAME)\n' ;\
+ echo "\#endif" ;\
+}
+
+__fwbin_sha = { \
+ echo " .section .rodata.$(FWSTR).sha" ;\
+ echo " .p2align ASM_LGPTR" ;\
+ echo ".global _fw_$(FWSTR)_sha_start" ;\
+ echo "_fw_$(FWSTR)_sha_start:" ;\
+ echo " .incbin \"$(fwobjdir)/$(FWNAME).sha.bin\"" ;\
+ echo ".global _fw_$(FWSTR)_sha_end" ;\
+ echo "_fw_$(FWSTR)_sha_end:" ;\
+}
+
+filechk_fwbin_ext = { \
+ $(filechk_fwbin) ;\
+ $(__fwbin_sha) ;\
+}
+
+$(obj)/%.gen.S: FORCE
+ $(call filechk,fwbin,.rodata.$(FWSTR),)
+
+$(obj)/%.extgen.S: $(obj)/%.sha.bin FORCE
+ $(call filechk,fwbin_ext,.pblext.$(FWSTR),a)
+
+$(obj)/%.sha.bin: $(obj)/%.sum FORCE
+ $(call if_changed,sha256bin)
+
+$(obj)/%.sum: FORCE
+ $(if $(wildcard $(fwdir)/$*), $(call if_changed,sha256sum,$(fwdir)/$*), @touch $@)
+
+clean-files += *.sha.bin *.sum
# The .o files depend on the binaries directly; the .S files don't.
-$(patsubst %,$(obj)/%.gen.o, $(fw-external-y)): $(obj)/%.gen.o: $(fwdir)/%
+$(patsubst %.gen.o,$(obj)/%.gen.o, $(obj-pbl-y)): $(obj)/%.gen.o: $(fwdir)/%
# The same for pbl:
-$(patsubst %,$(obj)/pbl-%.gen.o, $(fw-external-y)): $(obj)/pbl-%.gen.o: $(fwdir)/%
-
-obj-pbl-y += $(patsubst %,%.gen.o, $(fw-external-y))
+.SECONDEXPANSION:
+$(patsubst %.gen.o,$(obj)/%.gen.pbl.o, $(obj-pbl-y) $(pbl-y)): $(obj)/%.gen.pbl.o: $$(wildcard $(fwdir)/%)
+$(patsubst %.extgen.o,$(obj)/%.extgen.pbl.o, $(pbl-fwext-y)): $(obj)/%.extgen.pbl.o: $$(wildcard $(fwdir)/%)
-ifeq ($(KBUILD_SRC),)
-# Makefile.build only creates subdirectories for O= builds, but external
-# firmware might live outside the kernel source tree
-_dummy := $(foreach d,$(addprefix $(obj)/,$(dir $(fw-external-y))), $(shell [ -d $(d) ] || mkdir -p $(d)))
-endif
+pbl-y += $(pbl-fwext-y)
targets := $(patsubst $(obj)/%,%, \
$(shell find $(obj) -name \*.gen.S 2>/dev/null))
+targets += $(patsubst $(obj)/%,%, \
+ $(shell find $(obj) -name \*.extgen.S 2>/dev/null))
# just to build a built-in.o. Otherwise compilation fails when no
# firmware is built.