1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __FIRMWARE_UPLOAD_H
3 #define __FIRMWARE_UPLOAD_H
4 
5 #include <linux/device.h>
6 
7 /**
8  * enum fw_upload_prog - firmware upload progress codes
9  * @FW_UPLOAD_PROG_IDLE: there is no firmware upload in progress
10  * @FW_UPLOAD_PROG_RECEIVING: worker thread is receiving firmware data
11  * @FW_UPLOAD_PROG_PREPARING: target device is preparing for firmware upload
12  * @FW_UPLOAD_PROG_TRANSFERRING: data is being copied to the device
13  * @FW_UPLOAD_PROG_PROGRAMMING: device is performing the firmware update
14  * @FW_UPLOAD_PROG_MAX: Maximum progress code marker
15  */
16 enum fw_upload_prog {
17 	FW_UPLOAD_PROG_IDLE,
18 	FW_UPLOAD_PROG_RECEIVING,
19 	FW_UPLOAD_PROG_PREPARING,
20 	FW_UPLOAD_PROG_TRANSFERRING,
21 	FW_UPLOAD_PROG_PROGRAMMING,
22 	FW_UPLOAD_PROG_MAX
23 };
24 
25 struct fw_upload_priv {
26 	struct fw_upload *fw_upload;
27 	struct module *module;
28 	const char *name;
29 	const struct fw_upload_ops *ops;
30 	struct mutex lock;		  /* protect data structure contents */
31 	struct work_struct work;
32 	const u8 *data;			  /* pointer to update data */
33 	u32 remaining_size;		  /* size remaining to transfer */
34 	enum fw_upload_prog progress;
35 	enum fw_upload_prog err_progress; /* progress at time of failure */
36 	enum fw_upload_err err_code;	  /* security manager error code */
37 };
38 
39 #ifdef CONFIG_FW_UPLOAD
40 int fw_upload_start(struct fw_sysfs *fw_sysfs);
41 umode_t fw_upload_is_visible(struct kobject *kobj, struct attribute *attr, int n);
42 #else
43 static inline int fw_upload_start(struct fw_sysfs *fw_sysfs)
44 {
45 	return 0;
46 }
47 #endif
48 
49 #endif /* __FIRMWARE_UPLOAD_H */
50