^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) ====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) request_firmware API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) You would typically load firmware and then load it into your device somehow.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) The typical firmware work flow is reflected below::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) if(request_firmware(&fw_entry, $FIRMWARE, device) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) copy_fw_to_device(fw_entry->data, fw_entry->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) release_firmware(fw_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) Synchronous firmware requests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) =============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Synchronous firmware requests will wait until the firmware is found or until
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) an error is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) request_firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) .. kernel-doc:: drivers/base/firmware_loader/main.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) :functions: request_firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) firmware_request_nowarn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) .. kernel-doc:: drivers/base/firmware_loader/main.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) :functions: firmware_request_nowarn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) firmware_request_platform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) .. kernel-doc:: drivers/base/firmware_loader/main.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) :functions: firmware_request_platform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) request_firmware_direct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) .. kernel-doc:: drivers/base/firmware_loader/main.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) :functions: request_firmware_direct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) request_firmware_into_buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) .. kernel-doc:: drivers/base/firmware_loader/main.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) :functions: request_firmware_into_buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) Asynchronous firmware requests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ==============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) Asynchronous firmware requests allow driver code to not have to wait
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) until the firmware or an error is returned. Function callbacks are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) provided so that when the firmware or an error is found the driver is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) informed through the callback. request_firmware_nowait() cannot be called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) in atomic contexts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) request_firmware_nowait
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) .. kernel-doc:: drivers/base/firmware_loader/main.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) :functions: request_firmware_nowait
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) Special optimizations on reboot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) Some devices have an optimization in place to enable the firmware to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) retained during system reboot. When such optimizations are used the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) author must ensure the firmware is still available on resume from suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) this can be done with firmware_request_cache() instead of requesting for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) firmware to be loaded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) firmware_request_cache()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .. kernel-doc:: drivers/base/firmware_loader/main.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) :functions: firmware_request_cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) request firmware API expected driver use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) ========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) Once an API call returns you process the firmware and then release the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) firmware. For example if you used request_firmware() and it returns,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) the driver has the firmware image accessible in fw_entry->{data,size}.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) If something went wrong request_firmware() returns non-zero and fw_entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) is set to NULL. Once your driver is done with processing the firmware it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) can call release_firmware(fw_entry) to release the firmware image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) and any related resource.