xref: /openbmc/u-boot/include/fs_loader.h (revision 2cfcee82)
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 
9 #include <dm.h>
10 
11 /**
12  * struct firmware - A place for storing firmware and its attribute data.
13  *
14  * This holds information about a firmware and its content.
15  *
16  * @size: Size of a file
17  * @data: Buffer for file
18  * @priv: Firmware loader private fields
19  */
20 struct firmware {
21 	size_t size;
22 	const u8 *data;
23 	void *priv;
24 };
25 
26 /**
27  * struct phandle_part - A place for storing phandle of node and its partition
28  *
29  * This holds information about a phandle of the block device, and its
30  * partition where the firmware would be loaded from.
31  *
32  * @phandle: Phandle of storage device node
33  * @partition: Partition of block device
34  */
35 struct phandle_part {
36 	u32 phandle;
37 	u32 partition;
38 };
39 
40 /**
41  * struct phandle_part - A place for storing all supported storage devices
42  *
43  * This holds information about all supported storage devices for driver use.
44  *
45  * @phandlepart: Attribute data for block device.
46  * @mtdpart: MTD partition for ubi partition.
47  * @ubivol: UBI volume-name for ubifsmount.
48  */
49 struct device_platdata {
50 	struct phandle_part phandlepart;
51 	char *mtdpart;
52 	char *ubivol;
53 };
54 
55 /**
56  * release_firmware - Release the resource associated with a firmware image
57  * @firmware: Firmware resource to release
58  */
59 void release_firmware(struct firmware *firmware);
60 
61 /**
62  * request_firmware_into_buf - Load firmware into a previously allocated buffer.
63  * @plat: Platform data such as storage and partition firmware loading from.
64  * @name: Name of firmware file.
65  * @buf: Address of buffer to load firmware into.
66  * @size: Size of buffer.
67  * @offset: Offset of a file for start reading into buffer.
68  * @firmwarep: Pointer to firmware image.
69  *
70  * The firmware is loaded directly into the buffer pointed to by @buf and
71  * the @firmwarep data member is pointed at @buf.
72  *
73  * Return: Size of total read, negative value when error.
74  */
75 int request_firmware_into_buf(struct device_platdata *plat,
76 			      const char *name,
77 			      void *buf, size_t size, u32 offset,
78 			      struct firmware **firmwarep);
79 #endif
80