request_firmware.rst 2.7 KB

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