aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/remoteproc
diff options
context:
space:
mode:
authorSjur Brændeland <sjur.brandeland@stericsson.com>2013-02-21 12:15:35 -0500
committerOhad Ben-Cohen <ohad@wizery.com>2013-04-05 01:50:00 -0400
commite4b51414813faf5cdc89e373b2e44cdbead09459 (patch)
treea2134cf29ec8fbd25fe1ca7f34d1d87b0da51670 /drivers/remoteproc
parent95f9578163bc25bcbf391420373cf797d5321830 (diff)
remoteproc: parse STE-firmware and find resource table address
Parse the STE firmware and scan the TOC-table to find the address of the loaded resource table. Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com> [rebase patch; update terminology] Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r--drivers/remoteproc/ste_modem_rproc.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/drivers/remoteproc/ste_modem_rproc.c b/drivers/remoteproc/ste_modem_rproc.c
index a7743c069339..8cc588f38cd2 100644
--- a/drivers/remoteproc/ste_modem_rproc.c
+++ b/drivers/remoteproc/ste_modem_rproc.c
@@ -64,26 +64,18 @@ static int sproc_load_segments(struct rproc *rproc, const struct firmware *fw)
64} 64}
65 65
66/* Find the entry for resource table in the Table of Content */ 66/* Find the entry for resource table in the Table of Content */
67static struct ste_toc_entry *sproc_find_rsc_entry(const struct firmware *fw) 67static const struct ste_toc_entry *sproc_find_rsc_entry(const void *data)
68{ 68{
69 int i; 69 int i;
70 struct ste_toc *toc; 70 const struct ste_toc *toc;
71 71 toc = data;
72 if (!fw)
73 return NULL;
74
75 toc = (void *)fw->data;
76 72
77 /* Search the table for the resource table */ 73 /* Search the table for the resource table */
78 for (i = 0; i < SPROC_MAX_TOC_ENTRIES && 74 for (i = 0; i < SPROC_MAX_TOC_ENTRIES &&
79 toc->table[i].start != 0xffffffff; i++) { 75 toc->table[i].start != 0xffffffff; i++) {
80
81 if (!strncmp(toc->table[i].name, SPROC_RESOURCE_NAME, 76 if (!strncmp(toc->table[i].name, SPROC_RESOURCE_NAME,
82 sizeof(toc->table[i].name))) { 77 sizeof(toc->table[i].name)))
83 if (toc->table[i].start > fw->size)
84 return NULL;
85 return &toc->table[i]; 78 return &toc->table[i];
86 }
87 } 79 }
88 80
89 return NULL; 81 return NULL;
@@ -96,9 +88,12 @@ sproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw,
96{ 88{
97 struct sproc *sproc = rproc->priv; 89 struct sproc *sproc = rproc->priv;
98 struct resource_table *table; 90 struct resource_table *table;
99 struct ste_toc_entry *entry; 91 const struct ste_toc_entry *entry;
100 92
101 entry = sproc_find_rsc_entry(fw); 93 if (!fw)
94 return NULL;
95
96 entry = sproc_find_rsc_entry(fw->data);
102 if (!entry) { 97 if (!entry) {
103 sproc_err(sproc, "resource table not found in fw\n"); 98 sproc_err(sproc, "resource table not found in fw\n");
104 return NULL; 99 return NULL;
@@ -149,10 +144,30 @@ sproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw,
149 return table; 144 return table;
150} 145}
151 146
147/* Find the resource table inside the remote processor's firmware. */
148static struct resource_table *
149sproc_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw)
150{
151 struct sproc *sproc = rproc->priv;
152 const struct ste_toc_entry *entry;
153
154 if (!fw || !sproc->fw_addr)
155 return NULL;
156
157 entry = sproc_find_rsc_entry(sproc->fw_addr);
158 if (!entry) {
159 sproc_err(sproc, "resource table not found in fw\n");
160 return NULL;
161 }
162
163 return sproc->fw_addr + entry->start;
164}
165
152/* STE modem firmware handler operations */ 166/* STE modem firmware handler operations */
153const struct rproc_fw_ops sproc_fw_ops = { 167const struct rproc_fw_ops sproc_fw_ops = {
154 .load = sproc_load_segments, 168 .load = sproc_load_segments,
155 .find_rsc_table = sproc_find_rsc_table, 169 .find_rsc_table = sproc_find_rsc_table,
170 .find_loaded_rsc_table = sproc_find_loaded_rsc_table,
156}; 171};
157 172
158/* Kick the modem with specified notification id */ 173/* Kick the modem with specified notification id */