aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/remoteproc/remoteproc_elf_loader.c
diff options
context:
space:
mode:
authorSjur Brændeland <sjur.brandeland@stericsson.com>2012-06-19 03:08:18 -0400
committerOhad Ben-Cohen <ohad@wizery.com>2012-07-15 04:39:01 -0400
commit4afc89d66c60a372ec15e99eee93621f650b5d17 (patch)
treea6e8c4cd9ea726de73e967b2f0372230ba73a550 /drivers/remoteproc/remoteproc_elf_loader.c
parent72854fb042b15b6139031a59c4725b3d86708352 (diff)
remoteproc: Support custom firmware handlers
Firmware handling is made customizable. This is done by creating a separate ops structure for the firmware functions that depends on a particular firmware format (such as ELF). The ELF functions are default used unless the HW driver explicitly injects another firmware handler by updating rproc->fw_ops. The function rproc_da_to_va() is exported, as custom firmware handlers may need to use this function. Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com> [ohad: namespace fixes, whitespace fixes, style fixes] Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Diffstat (limited to 'drivers/remoteproc/remoteproc_elf_loader.c')
-rw-r--r--drivers/remoteproc/remoteproc_elf_loader.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c
index 2c6fe6ad2d95..6eebd01ea985 100644
--- a/drivers/remoteproc/remoteproc_elf_loader.c
+++ b/drivers/remoteproc/remoteproc_elf_loader.c
@@ -33,14 +33,14 @@
33#include "remoteproc_internal.h" 33#include "remoteproc_internal.h"
34 34
35/** 35/**
36 * rproc_fw_sanity_check() - Sanity Check ELF firmware image 36 * rproc_elf_sanity_check() - Sanity Check ELF firmware image
37 * @rproc: the remote processor handle 37 * @rproc: the remote processor handle
38 * @fw: the ELF firmware image 38 * @fw: the ELF firmware image
39 * 39 *
40 * Make sure this fw image is sane. 40 * Make sure this fw image is sane.
41 */ 41 */
42int 42static int
43rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) 43rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw)
44{ 44{
45 const char *name = rproc->firmware; 45 const char *name = rproc->firmware;
46 struct device *dev = &rproc->dev; 46 struct device *dev = &rproc->dev;
@@ -100,7 +100,7 @@ rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
100} 100}
101 101
102/** 102/**
103 * rproc_get_boot_addr() - Get rproc's boot address. 103 * rproc_elf_get_boot_addr() - Get rproc's boot address.
104 * @rproc: the remote processor handle 104 * @rproc: the remote processor handle
105 * @fw: the ELF firmware image 105 * @fw: the ELF firmware image
106 * 106 *
@@ -110,7 +110,8 @@ rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
110 * Note that the boot address is not a configurable property of all remote 110 * Note that the boot address is not a configurable property of all remote
111 * processors. Some will always boot at a specific hard-coded address. 111 * processors. Some will always boot at a specific hard-coded address.
112 */ 112 */
113u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) 113static
114u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
114{ 115{
115 struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data; 116 struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data;
116 117
@@ -118,7 +119,7 @@ u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
118} 119}
119 120
120/** 121/**
121 * rproc_load_segments() - load firmware segments to memory 122 * rproc_elf_load_segments() - load firmware segments to memory
122 * @rproc: remote processor which will be booted using these fw segments 123 * @rproc: remote processor which will be booted using these fw segments
123 * @fw: the ELF firmware image 124 * @fw: the ELF firmware image
124 * 125 *
@@ -141,8 +142,8 @@ u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
141 * directly allocate memory for every segment/resource. This is not yet 142 * directly allocate memory for every segment/resource. This is not yet
142 * supported, though. 143 * supported, though.
143 */ 144 */
144int 145static int
145rproc_load_segments(struct rproc *rproc, const struct firmware *fw) 146rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)
146{ 147{
147 struct device *dev = &rproc->dev; 148 struct device *dev = &rproc->dev;
148 struct elf32_hdr *ehdr; 149 struct elf32_hdr *ehdr;
@@ -208,7 +209,7 @@ rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
208} 209}
209 210
210/** 211/**
211 * rproc_find_rsc_table() - find the resource table 212 * rproc_elf_find_rsc_table() - find the resource table
212 * @rproc: the rproc handle 213 * @rproc: the rproc handle
213 * @fw: the ELF firmware image 214 * @fw: the ELF firmware image
214 * @tablesz: place holder for providing back the table size 215 * @tablesz: place holder for providing back the table size
@@ -222,8 +223,8 @@ rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
222 * size into @tablesz. If a valid table isn't found, NULL is returned 223 * size into @tablesz. If a valid table isn't found, NULL is returned
223 * (and @tablesz isn't set). 224 * (and @tablesz isn't set).
224 */ 225 */
225struct resource_table * 226static struct resource_table *
226rproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw, 227rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw,
227 int *tablesz) 228 int *tablesz)
228{ 229{
229 struct elf32_hdr *ehdr; 230 struct elf32_hdr *ehdr;
@@ -285,3 +286,10 @@ rproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw,
285 286
286 return table; 287 return table;
287} 288}
289
290const struct rproc_fw_ops rproc_elf_fw_ops = {
291 .load = rproc_elf_load_segments,
292 .find_rsc_table = rproc_elf_find_rsc_table,
293 .sanity_check = rproc_elf_sanity_check,
294 .get_boot_addr = rproc_elf_get_boot_addr
295};