Skip to content

Commit 530a1b5

Browse files
sumanannaandersson
authored andcommitted
remoteproc/omap: Add the rproc ops .da_to_va() implementation
An implementation for the rproc ops .da_to_va() has been added that provides the address translation between device addresses to kernel virtual addresses for internal RAMs present on that particular remote processor device. The implementation provides the translations based on the addresses parsed and stored during the probe. This ops gets invoked by the exported rproc_da_to_va() function and allows the remoteproc core's ELF loader to be able to load program data directly into the internal memories. Signed-off-by: Suman Anna <[email protected]> Signed-off-by: Tero Kristo <[email protected]> Reviewed-by: Andrew F. Davis <[email protected]> Acked-by: Mathieu Poirier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 4a03219 commit 530a1b5

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

drivers/remoteproc/omap_remoteproc.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,50 @@ static int omap_rproc_stop(struct rproc *rproc)
245245
return 0;
246246
}
247247

248+
/**
249+
* omap_rproc_da_to_va() - internal memory translation helper
250+
* @rproc: remote processor to apply the address translation for
251+
* @da: device address to translate
252+
* @len: length of the memory buffer
253+
*
254+
* Custom function implementing the rproc .da_to_va ops to provide address
255+
* translation (device address to kernel virtual address) for internal RAMs
256+
* present in a DSP or IPU device). The translated addresses can be used
257+
* either by the remoteproc core for loading, or by any rpmsg bus drivers.
258+
*
259+
* Return: translated virtual address in kernel memory space on success,
260+
* or NULL on failure.
261+
*/
262+
static void *omap_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
263+
{
264+
struct omap_rproc *oproc = rproc->priv;
265+
int i;
266+
u32 offset;
267+
268+
if (len <= 0)
269+
return NULL;
270+
271+
if (!oproc->num_mems)
272+
return NULL;
273+
274+
for (i = 0; i < oproc->num_mems; i++) {
275+
if (da >= oproc->mem[i].dev_addr && da + len <=
276+
oproc->mem[i].dev_addr + oproc->mem[i].size) {
277+
offset = da - oproc->mem[i].dev_addr;
278+
/* __force to make sparse happy with type conversion */
279+
return (__force void *)(oproc->mem[i].cpu_addr +
280+
offset);
281+
}
282+
}
283+
284+
return NULL;
285+
}
286+
248287
static const struct rproc_ops omap_rproc_ops = {
249288
.start = omap_rproc_start,
250289
.stop = omap_rproc_stop,
251290
.kick = omap_rproc_kick,
291+
.da_to_va = omap_rproc_da_to_va,
252292
};
253293

254294
static const struct omap_rproc_mem_data ipu_mems[] = {

0 commit comments

Comments
 (0)