aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/soc/qcom/mdt_loader.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/soc/qcom/mdt_loader.c')
-rw-r--r--drivers/soc/qcom/mdt_loader.c87
1 files changed, 62 insertions, 25 deletions
diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
index dc09d7ac905f..1c488024c698 100644
--- a/drivers/soc/qcom/mdt_loader.c
+++ b/drivers/soc/qcom/mdt_loader.c
@@ -74,23 +74,10 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw)
74} 74}
75EXPORT_SYMBOL_GPL(qcom_mdt_get_size); 75EXPORT_SYMBOL_GPL(qcom_mdt_get_size);
76 76
77/** 77static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
78 * qcom_mdt_load() - load the firmware which header is loaded as fw 78 const char *firmware, int pas_id, void *mem_region,
79 * @dev: device handle to associate resources with 79 phys_addr_t mem_phys, size_t mem_size,
80 * @fw: firmware object for the mdt file 80 phys_addr_t *reloc_base, bool pas_init)
81 * @firmware: name of the firmware, for construction of segment file names
82 * @pas_id: PAS identifier
83 * @mem_region: allocated memory region to load firmware into
84 * @mem_phys: physical address of allocated memory region
85 * @mem_size: size of the allocated memory region
86 * @reloc_base: adjusted physical address after relocation
87 *
88 * Returns 0 on success, negative errno otherwise.
89 */
90int qcom_mdt_load(struct device *dev, const struct firmware *fw,
91 const char *firmware, int pas_id, void *mem_region,
92 phys_addr_t mem_phys, size_t mem_size,
93 phys_addr_t *reloc_base)
94{ 81{
95 const struct elf32_phdr *phdrs; 82 const struct elf32_phdr *phdrs;
96 const struct elf32_phdr *phdr; 83 const struct elf32_phdr *phdr;
@@ -121,10 +108,12 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
121 if (!fw_name) 108 if (!fw_name)
122 return -ENOMEM; 109 return -ENOMEM;
123 110
124 ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size); 111 if (pas_init) {
125 if (ret) { 112 ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size);
126 dev_err(dev, "invalid firmware metadata\n"); 113 if (ret) {
127 goto out; 114 dev_err(dev, "invalid firmware metadata\n");
115 goto out;
116 }
128 } 117 }
129 118
130 for (i = 0; i < ehdr->e_phnum; i++) { 119 for (i = 0; i < ehdr->e_phnum; i++) {
@@ -144,10 +133,13 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
144 } 133 }
145 134
146 if (relocate) { 135 if (relocate) {
147 ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr); 136 if (pas_init) {
148 if (ret) { 137 ret = qcom_scm_pas_mem_setup(pas_id, mem_phys,
149 dev_err(dev, "unable to setup relocation\n"); 138 max_addr - min_addr);
150 goto out; 139 if (ret) {
140 dev_err(dev, "unable to setup relocation\n");
141 goto out;
142 }
151 } 143 }
152 144
153 /* 145 /*
@@ -202,7 +194,52 @@ out:
202 194
203 return ret; 195 return ret;
204} 196}
197
198/**
199 * qcom_mdt_load() - load the firmware which header is loaded as fw
200 * @dev: device handle to associate resources with
201 * @fw: firmware object for the mdt file
202 * @firmware: name of the firmware, for construction of segment file names
203 * @pas_id: PAS identifier
204 * @mem_region: allocated memory region to load firmware into
205 * @mem_phys: physical address of allocated memory region
206 * @mem_size: size of the allocated memory region
207 * @reloc_base: adjusted physical address after relocation
208 *
209 * Returns 0 on success, negative errno otherwise.
210 */
211int qcom_mdt_load(struct device *dev, const struct firmware *fw,
212 const char *firmware, int pas_id, void *mem_region,
213 phys_addr_t mem_phys, size_t mem_size,
214 phys_addr_t *reloc_base)
215{
216 return __qcom_mdt_load(dev, fw, firmware, pas_id, mem_region, mem_phys,
217 mem_size, reloc_base, true);
218}
205EXPORT_SYMBOL_GPL(qcom_mdt_load); 219EXPORT_SYMBOL_GPL(qcom_mdt_load);
206 220
221/**
222 * qcom_mdt_load_no_init() - load the firmware which header is loaded as fw
223 * @dev: device handle to associate resources with
224 * @fw: firmware object for the mdt file
225 * @firmware: name of the firmware, for construction of segment file names
226 * @pas_id: PAS identifier
227 * @mem_region: allocated memory region to load firmware into
228 * @mem_phys: physical address of allocated memory region
229 * @mem_size: size of the allocated memory region
230 * @reloc_base: adjusted physical address after relocation
231 *
232 * Returns 0 on success, negative errno otherwise.
233 */
234int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw,
235 const char *firmware, int pas_id,
236 void *mem_region, phys_addr_t mem_phys,
237 size_t mem_size, phys_addr_t *reloc_base)
238{
239 return __qcom_mdt_load(dev, fw, firmware, pas_id, mem_region, mem_phys,
240 mem_size, reloc_base, false);
241}
242EXPORT_SYMBOL_GPL(qcom_mdt_load_no_init);
243
207MODULE_DESCRIPTION("Firmware parser for Qualcomm MDT format"); 244MODULE_DESCRIPTION("Firmware parser for Qualcomm MDT format");
208MODULE_LICENSE("GPL v2"); 245MODULE_LICENSE("GPL v2");