xref: /openbmc/linux/drivers/base/firmware_loader/Kconfig (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
150f86aedSGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
206bfd3c8SLuis R. Rodriguezmenu "Firmware loader"
306bfd3c8SLuis R. Rodriguez
406bfd3c8SLuis R. Rodriguezconfig FW_LOADER
506bfd3c8SLuis R. Rodriguez	tristate "Firmware loading facility" if EXPERT
6*bedee105SArnd Bergmann	select CRYPTO_HASH if FW_LOADER_DEBUG
7*bedee105SArnd Bergmann	select CRYPTO_SHA256 if FW_LOADER_DEBUG
806bfd3c8SLuis R. Rodriguez	default y
906bfd3c8SLuis R. Rodriguez	help
1006bfd3c8SLuis R. Rodriguez	  This enables the firmware loading facility in the kernel. The kernel
1106bfd3c8SLuis R. Rodriguez	  will first look for built-in firmware, if it has any. Next, it will
1206bfd3c8SLuis R. Rodriguez	  look for the requested firmware in a series of filesystem paths:
1306bfd3c8SLuis R. Rodriguez
1406bfd3c8SLuis R. Rodriguez		o firmware_class path module parameter or kernel boot param
1506bfd3c8SLuis R. Rodriguez		o /lib/firmware/updates/UTS_RELEASE
1606bfd3c8SLuis R. Rodriguez		o /lib/firmware/updates
1706bfd3c8SLuis R. Rodriguez		o /lib/firmware/UTS_RELEASE
1806bfd3c8SLuis R. Rodriguez		o /lib/firmware
1906bfd3c8SLuis R. Rodriguez
2006bfd3c8SLuis R. Rodriguez	  Enabling this feature only increases your kernel image by about
2106bfd3c8SLuis R. Rodriguez	  828 bytes, enable this option unless you are certain you don't
2206bfd3c8SLuis R. Rodriguez	  need firmware.
2306bfd3c8SLuis R. Rodriguez
2406bfd3c8SLuis R. Rodriguez	  You typically want this built-in (=y) but you can also enable this
2506bfd3c8SLuis R. Rodriguez	  as a module, in which case the firmware_class module will be built.
2606bfd3c8SLuis R. Rodriguez	  You also want to be sure to enable this built-in if you are going to
2706bfd3c8SLuis R. Rodriguez	  enable built-in firmware (CONFIG_EXTRA_FIRMWARE).
2806bfd3c8SLuis R. Rodriguez
2902fe26f2SAmadeusz Sławińskiconfig FW_LOADER_DEBUG
3002fe26f2SAmadeusz Sławiński	bool "Log filenames and checksums for loaded firmware"
31*bedee105SArnd Bergmann	depends on CRYPTO = FW_LOADER || CRYPTO=y
3202fe26f2SAmadeusz Sławiński	depends on DYNAMIC_DEBUG
3302fe26f2SAmadeusz Sławiński	depends on FW_LOADER
3402fe26f2SAmadeusz Sławiński	default FW_LOADER
3502fe26f2SAmadeusz Sławiński	help
3602fe26f2SAmadeusz Sławiński	  Select this option to use dynamic debug to log firmware filenames and
3702fe26f2SAmadeusz Sławiński	  SHA256 checksums to the kernel log for each firmware file that is
3802fe26f2SAmadeusz Sławiński	  loaded.
3902fe26f2SAmadeusz Sławiński
4006bfd3c8SLuis R. Rodriguezif FW_LOADER
4106bfd3c8SLuis R. Rodriguez
4282fd7a81STakashi Iwaiconfig FW_LOADER_PAGED_BUF
4382fd7a81STakashi Iwai	bool
4482fd7a81STakashi Iwai
45e0c11a8bSRuss Weightconfig FW_LOADER_SYSFS
46e0c11a8bSRuss Weight	bool
47e0c11a8bSRuss Weight
4806bfd3c8SLuis R. Rodriguezconfig EXTRA_FIRMWARE
4906bfd3c8SLuis R. Rodriguez	string "Build named firmware blobs into the kernel binary"
5006bfd3c8SLuis R. Rodriguez	help
5106bfd3c8SLuis R. Rodriguez	  Device drivers which require firmware can typically deal with
5206bfd3c8SLuis R. Rodriguez	  having the kernel load firmware from the various supported
5306bfd3c8SLuis R. Rodriguez	  /lib/firmware/ paths. This option enables you to build into the
5406bfd3c8SLuis R. Rodriguez	  kernel firmware files. Built-in firmware searches are preceded
5506bfd3c8SLuis R. Rodriguez	  over firmware lookups using your filesystem over the supported
5606bfd3c8SLuis R. Rodriguez	  /lib/firmware paths documented on CONFIG_FW_LOADER.
5706bfd3c8SLuis R. Rodriguez
5806bfd3c8SLuis R. Rodriguez	  This may be useful for testing or if the firmware is required early on
5906bfd3c8SLuis R. Rodriguez	  in boot and cannot rely on the firmware being placed in an initrd or
6006bfd3c8SLuis R. Rodriguez	  initramfs.
6106bfd3c8SLuis R. Rodriguez
6206bfd3c8SLuis R. Rodriguez	  This option is a string and takes the (space-separated) names of the
6306bfd3c8SLuis R. Rodriguez	  firmware files -- the same names that appear in MODULE_FIRMWARE()
6406bfd3c8SLuis R. Rodriguez	  and request_firmware() in the source. These files should exist under
6506bfd3c8SLuis R. Rodriguez	  the directory specified by the EXTRA_FIRMWARE_DIR option, which is
6606bfd3c8SLuis R. Rodriguez	  /lib/firmware by default.
6706bfd3c8SLuis R. Rodriguez
6806bfd3c8SLuis R. Rodriguez	  For example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin", copy
6906bfd3c8SLuis R. Rodriguez	  the usb8388.bin file into /lib/firmware, and build the kernel. Then
7006bfd3c8SLuis R. Rodriguez	  any request_firmware("usb8388.bin") will be satisfied internally
7106bfd3c8SLuis R. Rodriguez	  inside the kernel without ever looking at your filesystem at runtime.
7206bfd3c8SLuis R. Rodriguez
7306bfd3c8SLuis R. Rodriguez	  WARNING: If you include additional firmware files into your binary
7406bfd3c8SLuis R. Rodriguez	  kernel image that are not available under the terms of the GPL,
7506bfd3c8SLuis R. Rodriguez	  then it may be a violation of the GPL to distribute the resulting
7606bfd3c8SLuis R. Rodriguez	  image since it combines both GPL and non-GPL work. You should
7706bfd3c8SLuis R. Rodriguez	  consult a lawyer of your own before distributing such an image.
7806bfd3c8SLuis R. Rodriguez
7936744c11SRandy Dunlap	  NOTE: Compressed files are not supported in EXTRA_FIRMWARE.
8036744c11SRandy Dunlap
8106bfd3c8SLuis R. Rodriguezconfig EXTRA_FIRMWARE_DIR
8206bfd3c8SLuis R. Rodriguez	string "Firmware blobs root directory"
8306bfd3c8SLuis R. Rodriguez	depends on EXTRA_FIRMWARE != ""
8406bfd3c8SLuis R. Rodriguez	default "/lib/firmware"
8506bfd3c8SLuis R. Rodriguez	help
8606bfd3c8SLuis R. Rodriguez	  This option controls the directory in which the kernel build system
8706bfd3c8SLuis R. Rodriguez	  looks for the firmware files listed in the EXTRA_FIRMWARE option.
8806bfd3c8SLuis R. Rodriguez
8906bfd3c8SLuis R. Rodriguezconfig FW_LOADER_USER_HELPER
9006bfd3c8SLuis R. Rodriguez	bool "Enable the firmware sysfs fallback mechanism"
91e0c11a8bSRuss Weight	select FW_LOADER_SYSFS
9282fd7a81STakashi Iwai	select FW_LOADER_PAGED_BUF
9306bfd3c8SLuis R. Rodriguez	help
9406bfd3c8SLuis R. Rodriguez	  This option enables a sysfs loading facility to enable firmware
9506bfd3c8SLuis R. Rodriguez	  loading to the kernel through userspace as a fallback mechanism
9606bfd3c8SLuis R. Rodriguez	  if and only if the kernel's direct filesystem lookup for the
9706bfd3c8SLuis R. Rodriguez	  firmware failed using the different /lib/firmware/ paths, or the
9806bfd3c8SLuis R. Rodriguez	  path specified in the firmware_class path module parameter, or the
9906bfd3c8SLuis R. Rodriguez	  firmware_class path kernel boot parameter if the firmware_class is
10006bfd3c8SLuis R. Rodriguez	  built-in. For details on how to work with the sysfs fallback mechanism
10106bfd3c8SLuis R. Rodriguez	  refer to Documentation/driver-api/firmware/fallback-mechanisms.rst.
10206bfd3c8SLuis R. Rodriguez
10306bfd3c8SLuis R. Rodriguez	  The direct filesystem lookup for firmware is always used first now.
10406bfd3c8SLuis R. Rodriguez
10506bfd3c8SLuis R. Rodriguez	  If the kernel's direct filesystem lookup for firmware fails to find
10606bfd3c8SLuis R. Rodriguez	  the requested firmware a sysfs fallback loading facility is made
10706bfd3c8SLuis R. Rodriguez	  available and userspace is informed about this through uevents.
10806bfd3c8SLuis R. Rodriguez	  The uevent can be suppressed if the driver explicitly requested it,
10906bfd3c8SLuis R. Rodriguez	  this is known as the driver using the custom fallback mechanism.
11006bfd3c8SLuis R. Rodriguez	  If the custom fallback mechanism is used userspace must always
11106bfd3c8SLuis R. Rodriguez	  acknowledge failure to find firmware as the timeout for the fallback
11206bfd3c8SLuis R. Rodriguez	  mechanism is disabled, and failed requests will linger forever.
11306bfd3c8SLuis R. Rodriguez
11406bfd3c8SLuis R. Rodriguez	  This used to be the default firmware loading facility, and udev used
11506bfd3c8SLuis R. Rodriguez	  to listen for uvents to load firmware for the kernel. The firmware
11606bfd3c8SLuis R. Rodriguez	  loading facility functionality in udev has been removed, as such it
11706bfd3c8SLuis R. Rodriguez	  can no longer be relied upon as a fallback mechanism. Linux no longer
11806bfd3c8SLuis R. Rodriguez	  relies on or uses a fallback mechanism in userspace. If you need to
11906bfd3c8SLuis R. Rodriguez	  rely on one refer to the permissively licensed firmwared:
12006bfd3c8SLuis R. Rodriguez
12106bfd3c8SLuis R. Rodriguez	  https://github.com/teg/firmwared
12206bfd3c8SLuis R. Rodriguez
12306bfd3c8SLuis R. Rodriguez	  Since this was the default firmware loading facility at one point,
12406bfd3c8SLuis R. Rodriguez	  old userspace may exist which relies upon it, and as such this
12506bfd3c8SLuis R. Rodriguez	  mechanism can never be removed from the kernel.
12606bfd3c8SLuis R. Rodriguez
12706bfd3c8SLuis R. Rodriguez	  You should only enable this functionality if you are certain you
12806bfd3c8SLuis R. Rodriguez	  require a fallback mechanism and have a userspace mechanism ready to
12906bfd3c8SLuis R. Rodriguez	  load firmware in case it is not found. One main reason for this may
13006bfd3c8SLuis R. Rodriguez	  be if you have drivers which require firmware built-in and for
13106bfd3c8SLuis R. Rodriguez	  whatever reason cannot place the required firmware in initramfs.
13206bfd3c8SLuis R. Rodriguez	  Another reason kernels may have this feature enabled is to support a
13306bfd3c8SLuis R. Rodriguez	  driver which explicitly relies on this fallback mechanism. Only two
13406bfd3c8SLuis R. Rodriguez	  drivers need this today:
13506bfd3c8SLuis R. Rodriguez
13606bfd3c8SLuis R. Rodriguez	    o CONFIG_LEDS_LP55XX_COMMON
13706bfd3c8SLuis R. Rodriguez	    o CONFIG_DELL_RBU
13806bfd3c8SLuis R. Rodriguez
13906bfd3c8SLuis R. Rodriguez	  Outside of supporting the above drivers, another reason for needing
14006bfd3c8SLuis R. Rodriguez	  this may be that your firmware resides outside of the paths the kernel
14106bfd3c8SLuis R. Rodriguez	  looks for and cannot possibly be specified using the firmware_class
14206bfd3c8SLuis R. Rodriguez	  path module parameter or kernel firmware_class path boot parameter
14306bfd3c8SLuis R. Rodriguez	  if firmware_class is built-in.
14406bfd3c8SLuis R. Rodriguez
14506bfd3c8SLuis R. Rodriguez	  A modern use case may be to temporarily mount a custom partition
14606bfd3c8SLuis R. Rodriguez	  during provisioning which is only accessible to userspace, and then
14706bfd3c8SLuis R. Rodriguez	  to use it to look for and fetch the required firmware. Such type of
14806bfd3c8SLuis R. Rodriguez	  driver functionality may not even ever be desirable upstream by
14906bfd3c8SLuis R. Rodriguez	  vendors, and as such is only required to be supported as an interface
15006bfd3c8SLuis R. Rodriguez	  for provisioning. Since udev's firmware loading facility has been
15106bfd3c8SLuis R. Rodriguez	  removed you can use firmwared or a fork of it to customize how you
15206bfd3c8SLuis R. Rodriguez	  want to load firmware based on uevents issued.
15306bfd3c8SLuis R. Rodriguez
15406bfd3c8SLuis R. Rodriguez	  Enabling this option will increase your kernel image size by about
15506bfd3c8SLuis R. Rodriguez	  13436 bytes.
15606bfd3c8SLuis R. Rodriguez
15706bfd3c8SLuis R. Rodriguez	  If you are unsure about this, say N here, unless you are Linux
15806bfd3c8SLuis R. Rodriguez	  distribution and need to support the above two drivers, or you are
15906bfd3c8SLuis R. Rodriguez	  certain you need to support some really custom firmware loading
16006bfd3c8SLuis R. Rodriguez	  facility in userspace.
16106bfd3c8SLuis R. Rodriguez
16206bfd3c8SLuis R. Rodriguezconfig FW_LOADER_USER_HELPER_FALLBACK
16306bfd3c8SLuis R. Rodriguez	bool "Force the firmware sysfs fallback mechanism when possible"
16406bfd3c8SLuis R. Rodriguez	depends on FW_LOADER_USER_HELPER
16506bfd3c8SLuis R. Rodriguez	help
16606bfd3c8SLuis R. Rodriguez	  Enabling this option forces a sysfs userspace fallback mechanism
16706bfd3c8SLuis R. Rodriguez	  to be used for all firmware requests which explicitly do not disable a
16806bfd3c8SLuis R. Rodriguez	  a fallback mechanism. Firmware calls which do prohibit a fallback
16906bfd3c8SLuis R. Rodriguez	  mechanism is request_firmware_direct(). This option is kept for
17006bfd3c8SLuis R. Rodriguez	  backward compatibility purposes given this precise mechanism can also
17106bfd3c8SLuis R. Rodriguez	  be enabled by setting the proc sysctl value to true:
17206bfd3c8SLuis R. Rodriguez
17306bfd3c8SLuis R. Rodriguez	       /proc/sys/kernel/firmware_config/force_sysfs_fallback
17406bfd3c8SLuis R. Rodriguez
17506bfd3c8SLuis R. Rodriguez	  If you are unsure about this, say N here.
17606bfd3c8SLuis R. Rodriguez
17782fd7a81STakashi Iwaiconfig FW_LOADER_COMPRESS
17882fd7a81STakashi Iwai	bool "Enable compressed firmware support"
17982fd7a81STakashi Iwai	help
18082fd7a81STakashi Iwai	  This option enables the support for loading compressed firmware
18182fd7a81STakashi Iwai	  files. The caller of firmware API receives the decompressed file
18282fd7a81STakashi Iwai	  content. The compressed file is loaded as a fallback, only after
18382fd7a81STakashi Iwai	  loading the raw file failed at first.
18482fd7a81STakashi Iwai
18536744c11SRandy Dunlap	  Compressed firmware support does not apply to firmware images
18636744c11SRandy Dunlap	  that are built into the kernel image (CONFIG_EXTRA_FIRMWARE).
18736744c11SRandy Dunlap
18823cfbc6eSTakashi Iwaiif FW_LOADER_COMPRESS
18923cfbc6eSTakashi Iwaiconfig FW_LOADER_COMPRESS_XZ
19023cfbc6eSTakashi Iwai	bool "Enable XZ-compressed firmware support"
19123cfbc6eSTakashi Iwai	select FW_LOADER_PAGED_BUF
19223cfbc6eSTakashi Iwai	select XZ_DEC
19307953c54SLinus Torvalds	default y
19423cfbc6eSTakashi Iwai	help
19523cfbc6eSTakashi Iwai	  This option adds the support for XZ-compressed files.
19623cfbc6eSTakashi Iwai	  The files have to be compressed with either none or crc32
19723cfbc6eSTakashi Iwai	  integrity check type (pass "-C crc32" option to xz command).
19823cfbc6eSTakashi Iwai
19923cfbc6eSTakashi Iwaiconfig FW_LOADER_COMPRESS_ZSTD
20023cfbc6eSTakashi Iwai	bool "Enable ZSTD-compressed firmware support"
20123cfbc6eSTakashi Iwai	select ZSTD_DECOMPRESS
20223cfbc6eSTakashi Iwai	help
20323cfbc6eSTakashi Iwai	  This option adds the support for ZSTD-compressed files.
20423cfbc6eSTakashi Iwai
20523cfbc6eSTakashi Iwaiendif # FW_LOADER_COMPRESS
20623cfbc6eSTakashi Iwai
207030cc787SMark Salyzynconfig FW_CACHE
208030cc787SMark Salyzyn	bool "Enable firmware caching during suspend"
209030cc787SMark Salyzyn	depends on PM_SLEEP
210030cc787SMark Salyzyn	default y if PM_SLEEP
211030cc787SMark Salyzyn	help
212030cc787SMark Salyzyn	  Because firmware caching generates uevent messages that are sent
213030cc787SMark Salyzyn	  over a netlink socket, it can prevent suspend on many platforms.
214030cc787SMark Salyzyn	  It is also not always useful, so on such platforms we have the
215030cc787SMark Salyzyn	  option.
216030cc787SMark Salyzyn
217030cc787SMark Salyzyn	  If unsure, say Y.
218030cc787SMark Salyzyn
21997730bbbSRuss Weightconfig FW_UPLOAD
22097730bbbSRuss Weight	bool "Enable users to initiate firmware updates using sysfs"
22197730bbbSRuss Weight	select FW_LOADER_SYSFS
22297730bbbSRuss Weight	select FW_LOADER_PAGED_BUF
22397730bbbSRuss Weight	help
22497730bbbSRuss Weight	  Enabling this option will allow device drivers to expose a persistent
22597730bbbSRuss Weight	  sysfs interface that allows firmware updates to be initiated from
22697730bbbSRuss Weight	  userspace. For example, FPGA based PCIe cards load firmware and FPGA
22797730bbbSRuss Weight	  images from local FLASH when the card boots. The images in FLASH may
22897730bbbSRuss Weight	  be updated with new images provided by the user. Enable this device
22997730bbbSRuss Weight	  to support cards that rely on user-initiated updates for firmware files.
23097730bbbSRuss Weight
23197730bbbSRuss Weight	  If unsure, say N.
23297730bbbSRuss Weight
23306bfd3c8SLuis R. Rodriguezendif # FW_LOADER
23406bfd3c8SLuis R. Rodriguezendmenu
235