1 # SPDX-License-Identifier: GPL-2.0
3 # kbuild file for firmware/
6 CONFIG_EXTRA_FIRMWARE_DIR
="firmware"
8 # Create $(fwabs) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a
9 # leading /, it's relative to $(srctree).
10 fwdir
:= $(subst $(quote
),,$(CONFIG_EXTRA_FIRMWARE_DIR
))
11 fwabs
:= $(addprefix $(srctree
)/,$(filter-out /%,$(fwdir
)))$(filter /%,$(fwdir
))
13 fw-external-y
:= $(subst $(quote
),,$(CONFIG_EXTRA_FIRMWARE
))
15 fw-external-
$(CONFIG_EXYNOS9610_ACPM
) += exynos9610_acpm_fvp.fw
16 fw-external-
$(CONFIG_EXYNOS9610_ACPM
) += exynos9610_acpm_tmu.fw
18 quiet_cmd_ihex
= IHEX
$@
19 cmd_ihex
= $(OBJCOPY
) -Iihex
-Obinary
$< $@
21 quiet_cmd_ihex2fw
= IHEX2FW
$@
22 cmd_ihex2fw
= $(objtree
)/$(obj
)/ihex2fw
$< $@
24 quiet_cmd_h16tofw
= H16TOFW
$@
25 cmd_h16tofw
= $(objtree
)/$(obj
)/ihex2fw
-w
$< $@
27 quiet_cmd_fwbin
= MK_FW
$@
28 cmd_fwbin
= FWNAME
="$(patsubst firmware/%.gen.S,%,$@)"; \
29 FWSTR
="$(subst /,_,$(subst .,_,$(subst -,_,$(patsubst \
30 firmware/%.gen.S,%,$@))))"; \
31 ASM_WORD
=$(if
$(CONFIG_64BIT
),.quad
,.long
); \
32 ASM_ALIGN
=$(if
$(CONFIG_64BIT
),3,2); \
33 PROGBITS
=$(if
$(CONFIG_ARM
),%,@
)progbits
; \
34 echo
"/* Generated by firmware/Makefile */" > $@
;\
35 echo
" .section .rodata" >>$@
;\
36 echo
" .p2align $${ASM_ALIGN}" >>$@
;\
37 echo
"_fw_$${FWSTR}_bin:" >>$@
;\
38 echo
" .incbin \"$(2)\"" >>$@
;\
39 echo
"_fw_end:" >>$@
;\
40 echo
" .section .rodata.str,\"aMS\",$${PROGBITS},1" >>$@
;\
41 echo
" .p2align $${ASM_ALIGN}" >>$@
;\
42 echo
"_fw_$${FWSTR}_name:" >>$@
;\
43 echo
" .string \"$$FWNAME\"" >>$@
;\
44 echo
" .section .builtin_fw,\"a\",$${PROGBITS}" >>$@
;\
45 echo
" .p2align $${ASM_ALIGN}" >>$@
;\
46 echo
" $${ASM_WORD} _fw_$${FWSTR}_name" >>$@
;\
47 echo
" $${ASM_WORD} _fw_$${FWSTR}_bin" >>$@
;\
48 echo
" $${ASM_WORD} _fw_end - _fw_$${FWSTR}_bin" >>$@
;
50 # One of these files will change, or come into existence, whenever
51 # the configuration changes between 32-bit and 64-bit. The .S files
52 # need to change when that happens.
53 wordsize_deps
:= $(wildcard include/config
/64bit.h
include/config
/32bit.h \
54 include/config
/ppc32.h
include/config
/ppc64.h \
55 include/config
/superh32.h
include/config
/superh64.h \
56 include/config
/x86_32.h
include/config
/x86_64.h \
59 $(patsubst %,$(obj
)/%.gen.S
, $(fw-external-y
)): %: $(wordsize_deps
)
60 $(call cmd
,fwbin
,$(fwabs
)/$(patsubst $(obj
)/%.gen.S
,%,$@
))
62 # The .o files depend on the binaries directly; the .S files don't.
63 $(patsubst %,$(obj
)/%.gen.o
, $(fw-external-y
)): $(obj
)/%.gen.o
: $(fwdir
)/%
65 # .ihex is used just as a simple way to hold binary files in a source tree
66 # where binaries are frowned upon. They are directly converted with objcopy.
67 $(obj
)/%: $(obj
)/%.ihex
70 obj-y
+= $(patsubst %,%.gen.o
, $(fw-external-y
))
73 # Makefile.build only creates subdirectories for O= builds, but external
74 # firmware might live outside the kernel source tree
75 _dummy
:= $(foreach d
,$(addprefix $(obj
)/,$(dir $(fw-external-y
))), $(shell [ -d
$(d
) ] || mkdir
-p
$(d
)))
78 targets
:= $(patsubst $(obj
)/%,%, \
79 $(shell find
$(obj
) -name \
*.gen.S
2>/dev
/null
))
80 # Without this, built-in.o won't be created when it's empty, and the
81 # final vmlinux link will fail.