1# SPDX-License-Identifier: GPL-2.0
2menu "Firmware loader"
3
4config FW_LOADER
5	tristate "Firmware loading facility" if EXPERT
6	default y
7	help
8	  This enables the firmware loading facility in the kernel. The kernel
9	  will first look for built-in firmware, if it has any. Next, it will
10	  look for the requested firmware in a series of filesystem paths:
11
12		o firmware_class path module parameter or kernel boot param
13		o /lib/firmware/updates/UTS_RELEASE
14		o /lib/firmware/updates
15		o /lib/firmware/UTS_RELEASE
16		o /lib/firmware
17
18	  Enabling this feature only increases your kernel image by about
19	  828 bytes, enable this option unless you are certain you don't
20	  need firmware.
21
22	  You typically want this built-in (=y) but you can also enable this
23	  as a module, in which case the firmware_class module will be built.
24	  You also want to be sure to enable this built-in if you are going to
25	  enable built-in firmware (CONFIG_EXTRA_FIRMWARE).
26
27if FW_LOADER
28
29config EXTRA_FIRMWARE
30	string "Build named firmware blobs into the kernel binary"
31	help
32	  Device drivers which require firmware can typically deal with
33	  having the kernel load firmware from the various supported
34	  /lib/firmware/ paths. This option enables you to build into the
35	  kernel firmware files. Built-in firmware searches are preceded
36	  over firmware lookups using your filesystem over the supported
37	  /lib/firmware paths documented on CONFIG_FW_LOADER.
38
39	  This may be useful for testing or if the firmware is required early on
40	  in boot and cannot rely on the firmware being placed in an initrd or
41	  initramfs.
42
43	  This option is a string and takes the (space-separated) names of the
44	  firmware files -- the same names that appear in MODULE_FIRMWARE()
45	  and request_firmware() in the source. These files should exist under
46	  the directory specified by the EXTRA_FIRMWARE_DIR option, which is
47	  /lib/firmware by default.
48
49	  For example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin", copy
50	  the usb8388.bin file into /lib/firmware, and build the kernel. Then
51	  any request_firmware("usb8388.bin") will be satisfied internally
52	  inside the kernel without ever looking at your filesystem at runtime.
53
54	  WARNING: If you include additional firmware files into your binary
55	  kernel image that are not available under the terms of the GPL,
56	  then it may be a violation of the GPL to distribute the resulting
57	  image since it combines both GPL and non-GPL work. You should
58	  consult a lawyer of your own before distributing such an image.
59
60config EXTRA_FIRMWARE_DIR
61	string "Firmware blobs root directory"
62	depends on EXTRA_FIRMWARE != ""
63	default "/lib/firmware"
64	help
65	  This option controls the directory in which the kernel build system
66	  looks for the firmware files listed in the EXTRA_FIRMWARE option.
67
68config FW_LOADER_USER_HELPER
69	bool "Enable the firmware sysfs fallback mechanism"
70	help
71	  This option enables a sysfs loading facility to enable firmware
72	  loading to the kernel through userspace as a fallback mechanism
73	  if and only if the kernel's direct filesystem lookup for the
74	  firmware failed using the different /lib/firmware/ paths, or the
75	  path specified in the firmware_class path module parameter, or the
76	  firmware_class path kernel boot parameter if the firmware_class is
77	  built-in. For details on how to work with the sysfs fallback mechanism
78	  refer to Documentation/driver-api/firmware/fallback-mechanisms.rst.
79
80	  The direct filesystem lookup for firmware is always used first now.
81
82	  If the kernel's direct filesystem lookup for firmware fails to find
83	  the requested firmware a sysfs fallback loading facility is made
84	  available and userspace is informed about this through uevents.
85	  The uevent can be suppressed if the driver explicitly requested it,
86	  this is known as the driver using the custom fallback mechanism.
87	  If the custom fallback mechanism is used userspace must always
88	  acknowledge failure to find firmware as the timeout for the fallback
89	  mechanism is disabled, and failed requests will linger forever.
90
91	  This used to be the default firmware loading facility, and udev used
92	  to listen for uvents to load firmware for the kernel. The firmware
93	  loading facility functionality in udev has been removed, as such it
94	  can no longer be relied upon as a fallback mechanism. Linux no longer
95	  relies on or uses a fallback mechanism in userspace. If you need to
96	  rely on one refer to the permissively licensed firmwared:
97
98	  https://github.com/teg/firmwared
99
100	  Since this was the default firmware loading facility at one point,
101	  old userspace may exist which relies upon it, and as such this
102	  mechanism can never be removed from the kernel.
103
104	  You should only enable this functionality if you are certain you
105	  require a fallback mechanism and have a userspace mechanism ready to
106	  load firmware in case it is not found. One main reason for this may
107	  be if you have drivers which require firmware built-in and for
108	  whatever reason cannot place the required firmware in initramfs.
109	  Another reason kernels may have this feature enabled is to support a
110	  driver which explicitly relies on this fallback mechanism. Only two
111	  drivers need this today:
112
113	    o CONFIG_LEDS_LP55XX_COMMON
114	    o CONFIG_DELL_RBU
115
116	  Outside of supporting the above drivers, another reason for needing
117	  this may be that your firmware resides outside of the paths the kernel
118	  looks for and cannot possibly be specified using the firmware_class
119	  path module parameter or kernel firmware_class path boot parameter
120	  if firmware_class is built-in.
121
122	  A modern use case may be to temporarily mount a custom partition
123	  during provisioning which is only accessible to userspace, and then
124	  to use it to look for and fetch the required firmware. Such type of
125	  driver functionality may not even ever be desirable upstream by
126	  vendors, and as such is only required to be supported as an interface
127	  for provisioning. Since udev's firmware loading facility has been
128	  removed you can use firmwared or a fork of it to customize how you
129	  want to load firmware based on uevents issued.
130
131	  Enabling this option will increase your kernel image size by about
132	  13436 bytes.
133
134	  If you are unsure about this, say N here, unless you are Linux
135	  distribution and need to support the above two drivers, or you are
136	  certain you need to support some really custom firmware loading
137	  facility in userspace.
138
139config FW_LOADER_USER_HELPER_FALLBACK
140	bool "Force the firmware sysfs fallback mechanism when possible"
141	depends on FW_LOADER_USER_HELPER
142	help
143	  Enabling this option forces a sysfs userspace fallback mechanism
144	  to be used for all firmware requests which explicitly do not disable a
145	  a fallback mechanism. Firmware calls which do prohibit a fallback
146	  mechanism is request_firmware_direct(). This option is kept for
147          backward compatibility purposes given this precise mechanism can also
148	  be enabled by setting the proc sysctl value to true:
149
150	       /proc/sys/kernel/firmware_config/force_sysfs_fallback
151
152	  If you are unsure about this, say N here.
153
154endif # FW_LOADER
155endmenu
156