Commit df85b2d767aad90fd2746f993fcd66dd322768f8

Authored by Markus Trippelsdorf
Committed by Linus Torvalds
1 parent 7318413077

firmware: Restore support for built-in firmware

Commit 5620a0d1aac ("firmware: delete in-kernel firmware") removed the
entire firmware directory.  Unfortunately it thereby also removed the
support for built-in firmware.

This restores the ability to build firmware directly into the kernel by
pruning the original Makefile to the necessary minimum.  The default for
EXTRA_FIRMWARE_DIR is now the standard directory /lib/firmware/.

Fixes: 5620a0d1aac ("firmware: delete in-kernel firmware")
Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Acked-by: Greg K-H <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 4 changed files with 71 additions and 5 deletions Side-by-side Diff

... ... @@ -562,7 +562,7 @@
562 562  
563 563 # Objects we will link into vmlinux / subdirs we need to visit
564 564 init-y := init/
565   -drivers-y := drivers/ sound/
  565 +drivers-y := drivers/ sound/ firmware/
566 566 net-y := net/
567 567 libs-y := lib/
568 568 core-y := usr/
drivers/base/Kconfig
... ... @@ -140,13 +140,10 @@
140 140 config EXTRA_FIRMWARE_DIR
141 141 string "Firmware blobs root directory"
142 142 depends on EXTRA_FIRMWARE != ""
143   - default "firmware"
  143 + default "/lib/firmware"
144 144 help
145 145 This option controls the directory in which the kernel build system
146 146 looks for the firmware files listed in the EXTRA_FIRMWARE option.
147   - The default is firmware/ in the kernel source tree, but by changing
148   - this option you can point it elsewhere, such as /lib/firmware/ or
149   - some other directory containing the firmware files.
150 147  
151 148 config FW_LOADER_USER_HELPER
152 149 bool
  1 +*.gen.S
  2 +*.fw
  3 +*.bin
  4 +*.csp
  5 +*.dsp
  6 +ihex2fw
  1 +#
  2 +# kbuild file for firmware/
  3 +#
  4 +
  5 +# Create $(fwabs) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a
  6 +# leading /, it's relative to $(srctree).
  7 +fwdir := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE_DIR))
  8 +fwabs := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir))
  9 +
  10 +fw-external-y := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE))
  11 +
  12 +quiet_cmd_fwbin = MK_FW $@
  13 + cmd_fwbin = FWNAME="$(patsubst firmware/%.gen.S,%,$@)"; \
  14 + FWSTR="$(subst /,_,$(subst .,_,$(subst -,_,$(patsubst \
  15 + firmware/%.gen.S,%,$@))))"; \
  16 + ASM_WORD=$(if $(CONFIG_64BIT),.quad,.long); \
  17 + ASM_ALIGN=$(if $(CONFIG_64BIT),3,2); \
  18 + PROGBITS=$(if $(CONFIG_ARM),%,@)progbits; \
  19 + echo "/* Generated by firmware/Makefile */" > $@;\
  20 + echo " .section .rodata" >>$@;\
  21 + echo " .p2align $${ASM_ALIGN}" >>$@;\
  22 + echo "_fw_$${FWSTR}_bin:" >>$@;\
  23 + echo " .incbin \"$(2)\"" >>$@;\
  24 + echo "_fw_end:" >>$@;\
  25 + echo " .section .rodata.str,\"aMS\",$${PROGBITS},1" >>$@;\
  26 + echo " .p2align $${ASM_ALIGN}" >>$@;\
  27 + echo "_fw_$${FWSTR}_name:" >>$@;\
  28 + echo " .string \"$$FWNAME\"" >>$@;\
  29 + echo " .section .builtin_fw,\"a\",$${PROGBITS}" >>$@;\
  30 + echo " .p2align $${ASM_ALIGN}" >>$@;\
  31 + echo " $${ASM_WORD} _fw_$${FWSTR}_name" >>$@;\
  32 + echo " $${ASM_WORD} _fw_$${FWSTR}_bin" >>$@;\
  33 + echo " $${ASM_WORD} _fw_end - _fw_$${FWSTR}_bin" >>$@;
  34 +
  35 +# One of these files will change, or come into existence, whenever
  36 +# the configuration changes between 32-bit and 64-bit. The .S files
  37 +# need to change when that happens.
  38 +wordsize_deps := $(wildcard include/config/64bit.h include/config/32bit.h \
  39 + include/config/ppc32.h include/config/ppc64.h \
  40 + include/config/superh32.h include/config/superh64.h \
  41 + include/config/x86_32.h include/config/x86_64.h \
  42 + firmware/Makefile)
  43 +
  44 +$(patsubst %,$(obj)/%.gen.S, $(fw-external-y)): %: $(wordsize_deps) \
  45 + include/config/extra/firmware/dir.h
  46 + $(call cmd,fwbin,$(fwabs)/$(patsubst $(obj)/%.gen.S,%,$@))
  47 +
  48 +# The .o files depend on the binaries directly; the .S files don't.
  49 +$(patsubst %,$(obj)/%.gen.o, $(fw-external-y)): $(obj)/%.gen.o: $(fwdir)/%
  50 +
  51 +obj-y += $(patsubst %,%.gen.o, $(fw-external-y))
  52 +
  53 +ifeq ($(KBUILD_SRC),)
  54 +# Makefile.build only creates subdirectories for O= builds, but external
  55 +# firmware might live outside the kernel source tree
  56 +_dummy := $(foreach d,$(addprefix $(obj)/,$(dir $(fw-external-y))), $(shell [ -d $(d) ] || mkdir -p $(d)))
  57 +endif
  58 +
  59 +targets := $(patsubst $(obj)/%,%, \
  60 + $(shell find $(obj) -name \*.gen.S 2>/dev/null))
  61 +# Without this, built-in.o won't be created when it's empty, and the
  62 +# final vmlinux link will fail.
  63 +obj- := dummy