aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSricharan R <sricharan@codeaurora.org>2018-06-04 16:30:35 -0400
committerBjorn Andersson <bjorn.andersson@linaro.org>2018-06-18 18:55:31 -0400
commit0e622e80191e75c99b6ecc265c140a37d81e7a63 (patch)
treed91d67f6dc1946328f8926d2584d84aa946c5675
parentce397d215ccd07b8ae3f71db689aedb85d56ab40 (diff)
remoteproc: qcom: mdt_loader: Make the firmware authentication optional
qcom_mdt_load function loads the mdt type firmware and initialises the secure memory as well. Make the initialisation only when requested by the caller, so that the function can be used by self-authenticating remoteproc as well. Acked-by: Andy Gross <andy.gross@linaro.org> Signed-off-by: Sricharan R <sricharan@codeaurora.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r--drivers/soc/qcom/mdt_loader.c87
-rw-r--r--include/linux/soc/qcom/mdt_loader.h4
2 files changed, 66 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");
diff --git a/include/linux/soc/qcom/mdt_loader.h b/include/linux/soc/qcom/mdt_loader.h
index 5b98bbdabc25..944b06aefb0f 100644
--- a/include/linux/soc/qcom/mdt_loader.h
+++ b/include/linux/soc/qcom/mdt_loader.h
@@ -17,4 +17,8 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
17 phys_addr_t mem_phys, size_t mem_size, 17 phys_addr_t mem_phys, size_t mem_size,
18 phys_addr_t *reloc_base); 18 phys_addr_t *reloc_base);
19 19
20int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw,
21 const char *fw_name, int pas_id, void *mem_region,
22 phys_addr_t mem_phys, size_t mem_size,
23 phys_addr_t *reloc_base);
20#endif 24#endif