diff options
author | Sjur Brændeland <sjur.brandeland@stericsson.com> | 2012-06-19 03:08:18 -0400 |
---|---|---|
committer | Ohad Ben-Cohen <ohad@wizery.com> | 2012-07-15 04:39:01 -0400 |
commit | 4afc89d66c60a372ec15e99eee93621f650b5d17 (patch) | |
tree | a6e8c4cd9ea726de73e967b2f0372230ba73a550 /drivers/remoteproc/remoteproc_internal.h | |
parent | 72854fb042b15b6139031a59c4725b3d86708352 (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_internal.h')
-rw-r--r-- | drivers/remoteproc/remoteproc_internal.h | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index a44e1926e4c3..a690ebe7aa51 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h | |||
@@ -25,6 +25,23 @@ | |||
25 | 25 | ||
26 | struct rproc; | 26 | struct rproc; |
27 | 27 | ||
28 | /** | ||
29 | * struct rproc_fw_ops - firmware format specific operations. | ||
30 | * @find_rsc_table: finds the resource table inside the firmware image | ||
31 | * @load: load firmeware to memory, where the remote processor | ||
32 | * expects to find it | ||
33 | * @sanity_check: sanity check the fw image | ||
34 | * @get_boot_addr: get boot address to entry point specified in firmware | ||
35 | */ | ||
36 | struct rproc_fw_ops { | ||
37 | struct resource_table *(*find_rsc_table) (struct rproc *rproc, | ||
38 | const struct firmware *fw, | ||
39 | int *tablesz); | ||
40 | int (*load)(struct rproc *rproc, const struct firmware *fw); | ||
41 | int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); | ||
42 | u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); | ||
43 | }; | ||
44 | |||
28 | /* from remoteproc_core.c */ | 45 | /* from remoteproc_core.c */ |
29 | void rproc_release(struct kref *kref); | 46 | void rproc_release(struct kref *kref); |
30 | irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); | 47 | irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); |
@@ -47,11 +64,43 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); | |||
47 | 64 | ||
48 | void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); | 65 | void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); |
49 | 66 | ||
67 | static inline | ||
68 | int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) | ||
69 | { | ||
70 | if (rproc->fw_ops->sanity_check) | ||
71 | return rproc->fw_ops->sanity_check(rproc, fw); | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static inline | ||
77 | u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) | ||
78 | { | ||
79 | if (rproc->fw_ops->get_boot_addr) | ||
80 | return rproc->fw_ops->get_boot_addr(rproc, fw); | ||
81 | |||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static inline | ||
86 | int rproc_load_segments(struct rproc *rproc, const struct firmware *fw) | ||
87 | { | ||
88 | if (rproc->fw_ops->load) | ||
89 | return rproc->fw_ops->load(rproc, fw); | ||
90 | |||
91 | return -EINVAL; | ||
92 | } | ||
93 | |||
94 | static inline | ||
50 | struct resource_table *rproc_find_rsc_table(struct rproc *rproc, | 95 | struct resource_table *rproc_find_rsc_table(struct rproc *rproc, |
51 | const struct firmware *fw, | 96 | const struct firmware *fw, int *tablesz) |
52 | int *tablesz); | 97 | { |
53 | int rproc_load_segments(struct rproc *rproc, const struct firmware *fw); | 98 | if (rproc->fw_ops->find_rsc_table) |
54 | int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw); | 99 | return rproc->fw_ops->find_rsc_table(rproc, fw, tablesz); |
55 | u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw); | 100 | |
101 | return NULL; | ||
102 | } | ||
103 | |||
104 | extern const struct rproc_fw_ops rproc_elf_fw_ops; | ||
56 | 105 | ||
57 | #endif /* REMOTEPROC_INTERNAL_H */ | 106 | #endif /* REMOTEPROC_INTERNAL_H */ |