diff options
| author | Markus Trippelsdorf <markus@trippelsdorf.de> | 2017-09-16 05:01:16 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-16 13:58:48 -0400 |
| commit | df85b2d767aad90fd2746f993fcd66dd322768f8 (patch) | |
| tree | c2a2ab7761d941750255218b0a08cbbec10f95ad | |
| parent | 7318413077a5141a50a753b1fab687b7907eef16 (diff) | |
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>
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | drivers/base/Kconfig | 5 | ||||
| -rw-r--r-- | firmware/.gitignore | 6 | ||||
| -rw-r--r-- | firmware/Makefile | 63 |
4 files changed, 71 insertions, 5 deletions
| @@ -562,7 +562,7 @@ scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \ | |||
| 562 | 562 | ||
| 563 | # Objects we will link into vmlinux / subdirs we need to visit | 563 | # Objects we will link into vmlinux / subdirs we need to visit |
| 564 | init-y := init/ | 564 | init-y := init/ |
| 565 | drivers-y := drivers/ sound/ | 565 | drivers-y := drivers/ sound/ firmware/ |
| 566 | net-y := net/ | 566 | net-y := net/ |
| 567 | libs-y := lib/ | 567 | libs-y := lib/ |
| 568 | core-y := usr/ | 568 | core-y := usr/ |
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index f046d21de57d..1a5f6a157a57 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig | |||
| @@ -140,13 +140,10 @@ config EXTRA_FIRMWARE | |||
| 140 | config EXTRA_FIRMWARE_DIR | 140 | config EXTRA_FIRMWARE_DIR |
| 141 | string "Firmware blobs root directory" | 141 | string "Firmware blobs root directory" |
| 142 | depends on EXTRA_FIRMWARE != "" | 142 | depends on EXTRA_FIRMWARE != "" |
| 143 | default "firmware" | 143 | default "/lib/firmware" |
| 144 | help | 144 | help |
| 145 | This option controls the directory in which the kernel build system | 145 | This option controls the directory in which the kernel build system |
| 146 | looks for the firmware files listed in the EXTRA_FIRMWARE option. | 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 | config FW_LOADER_USER_HELPER | 148 | config FW_LOADER_USER_HELPER |
| 152 | bool | 149 | bool |
diff --git a/firmware/.gitignore b/firmware/.gitignore new file mode 100644 index 000000000000..d9c69017bc9a --- /dev/null +++ b/firmware/.gitignore | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | *.gen.S | ||
| 2 | *.fw | ||
| 3 | *.bin | ||
| 4 | *.csp | ||
| 5 | *.dsp | ||
| 6 | ihex2fw | ||
diff --git a/firmware/Makefile b/firmware/Makefile new file mode 100644 index 000000000000..fa0808853883 --- /dev/null +++ b/firmware/Makefile | |||
| @@ -0,0 +1,63 @@ | |||
| 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 | ||
