Tien Fong Chee | 5ca878b | 2018-07-06 16:28:03 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 Intel Corporation <www.intel.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0 |
| 5 | */ |
| 6 | #ifndef _FS_LOADER_H_ |
| 7 | #define _FS_LOADER_H_ |
| 8 | |
Simon Glass | ef8a4e6 | 2020-07-19 10:15:38 -0600 | [diff] [blame] | 9 | struct udevice; |
Tien Fong Chee | 5ca878b | 2018-07-06 16:28:03 +0800 | [diff] [blame] | 10 | |
| 11 | /** |
Tien Fong Chee | 5ca878b | 2018-07-06 16:28:03 +0800 | [diff] [blame] | 12 | * struct phandle_part - A place for storing phandle of node and its partition |
| 13 | * |
| 14 | * This holds information about a phandle of the block device, and its |
| 15 | * partition where the firmware would be loaded from. |
| 16 | * |
| 17 | * @phandle: Phandle of storage device node |
| 18 | * @partition: Partition of block device |
| 19 | */ |
| 20 | struct phandle_part { |
| 21 | u32 phandle; |
| 22 | u32 partition; |
| 23 | }; |
| 24 | |
| 25 | /** |
| 26 | * struct phandle_part - A place for storing all supported storage devices |
| 27 | * |
| 28 | * This holds information about all supported storage devices for driver use. |
| 29 | * |
| 30 | * @phandlepart: Attribute data for block device. |
| 31 | * @mtdpart: MTD partition for ubi partition. |
| 32 | * @ubivol: UBI volume-name for ubifsmount. |
| 33 | */ |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 34 | struct device_plat { |
Tien Fong Chee | 5ca878b | 2018-07-06 16:28:03 +0800 | [diff] [blame] | 35 | struct phandle_part phandlepart; |
| 36 | char *mtdpart; |
| 37 | char *ubivol; |
| 38 | }; |
| 39 | |
| 40 | /** |
Tien Fong Chee | 5ca878b | 2018-07-06 16:28:03 +0800 | [diff] [blame] | 41 | * request_firmware_into_buf - Load firmware into a previously allocated buffer. |
Tien Fong Chee | e8b7970 | 2018-12-10 21:29:44 +0800 | [diff] [blame] | 42 | * @dev: An instance of a driver. |
Tien Fong Chee | 5ca878b | 2018-07-06 16:28:03 +0800 | [diff] [blame] | 43 | * @name: Name of firmware file. |
| 44 | * @buf: Address of buffer to load firmware into. |
| 45 | * @size: Size of buffer. |
| 46 | * @offset: Offset of a file for start reading into buffer. |
Tien Fong Chee | 5ca878b | 2018-07-06 16:28:03 +0800 | [diff] [blame] | 47 | * |
Tien Fong Chee | e8b7970 | 2018-12-10 21:29:44 +0800 | [diff] [blame] | 48 | * The firmware is loaded directly into the buffer pointed to by @buf. |
Tien Fong Chee | 5ca878b | 2018-07-06 16:28:03 +0800 | [diff] [blame] | 49 | * |
| 50 | * Return: Size of total read, negative value when error. |
| 51 | */ |
Tien Fong Chee | e8b7970 | 2018-12-10 21:29:44 +0800 | [diff] [blame] | 52 | int request_firmware_into_buf(struct udevice *dev, |
Tien Fong Chee | 5ca878b | 2018-07-06 16:28:03 +0800 | [diff] [blame] | 53 | const char *name, |
Tien Fong Chee | e8b7970 | 2018-12-10 21:29:44 +0800 | [diff] [blame] | 54 | void *buf, size_t size, u32 offset); |
Sean Anderson | 5cd0cb3 | 2022-12-29 11:52:59 -0500 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * get_fs_loader() - Get the chosen filesystem loader |
| 58 | * @dev: Where to store the device |
| 59 | * |
| 60 | * This gets a filesystem loader device based on the value of |
| 61 | * /chosen/firmware-loader. If no such property exists, it returns a |
| 62 | * firmware loader which is configured by environmental variables. |
| 63 | * |
| 64 | * Return: 0 on success, negative value on error |
| 65 | */ |
| 66 | int get_fs_loader(struct udevice **dev); |
Tien Fong Chee | 5ca878b | 2018-07-06 16:28:03 +0800 | [diff] [blame] | 67 | #endif |