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