1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __QCOM_MDT_LOADER_H__
3 #define __QCOM_MDT_LOADER_H__
4 
5 #include <linux/types.h>
6 
7 #define QCOM_MDT_TYPE_MASK	(7 << 24)
8 #define QCOM_MDT_TYPE_HASH	(2 << 24)
9 #define QCOM_MDT_RELOCATABLE	BIT(27)
10 
11 struct device;
12 struct firmware;
13 
14 #if IS_ENABLED(CONFIG_QCOM_MDT_LOADER)
15 
16 ssize_t qcom_mdt_get_size(const struct firmware *fw);
17 int qcom_mdt_load(struct device *dev, const struct firmware *fw,
18 		  const char *fw_name, int pas_id, void *mem_region,
19 		  phys_addr_t mem_phys, size_t mem_size,
20 		  phys_addr_t *reloc_base);
21 
22 int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw,
23 			  const char *fw_name, int pas_id, void *mem_region,
24 			  phys_addr_t mem_phys, size_t mem_size,
25 			  phys_addr_t *reloc_base);
26 void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len);
27 
28 #else /* !IS_ENABLED(CONFIG_QCOM_MDT_LOADER) */
29 
qcom_mdt_get_size(const struct firmware * fw)30 static inline ssize_t qcom_mdt_get_size(const struct firmware *fw)
31 {
32 	return -ENODEV;
33 }
34 
qcom_mdt_load(struct device * dev,const struct firmware * fw,const char * fw_name,int pas_id,void * mem_region,phys_addr_t mem_phys,size_t mem_size,phys_addr_t * reloc_base)35 static inline int qcom_mdt_load(struct device *dev, const struct firmware *fw,
36 				const char *fw_name, int pas_id,
37 				void *mem_region, phys_addr_t mem_phys,
38 				size_t mem_size, phys_addr_t *reloc_base)
39 {
40 	return -ENODEV;
41 }
42 
qcom_mdt_load_no_init(struct device * dev,const struct firmware * fw,const char * fw_name,int pas_id,void * mem_region,phys_addr_t mem_phys,size_t mem_size,phys_addr_t * reloc_base)43 static inline int qcom_mdt_load_no_init(struct device *dev,
44 					const struct firmware *fw,
45 					const char *fw_name, int pas_id,
46 					void *mem_region, phys_addr_t mem_phys,
47 					size_t mem_size,
48 					phys_addr_t *reloc_base)
49 {
50 	return -ENODEV;
51 }
52 
qcom_mdt_read_metadata(const struct firmware * fw,size_t * data_len)53 static inline void *qcom_mdt_read_metadata(const struct firmware *fw,
54 					   size_t *data_len)
55 {
56 	return ERR_PTR(-ENODEV);
57 }
58 
59 #endif /* !IS_ENABLED(CONFIG_QCOM_MDT_LOADER) */
60 
61 #endif
62