Skip to content

Commit 4a03219

Browse files
sumanannaandersson
authored andcommitted
remoteproc/omap: Add support to parse internal memories from DT
The OMAP remoteproc driver has been enhanced to parse and store the kernel mappings for different internal RAM memories that may be present within each remote processor IP subsystem. Different devices have varying memories present on current SoCs. The current support handles the L2RAM for all IPU devices on OMAP4+ SoCs. The DSPs on OMAP4/OMAP5 only have Unicaches and do not have any L1 or L2 RAM memories. IPUs are expected to have the L2RAM at a fixed device address of 0x20000000, based on the current limitations on Attribute MMU configurations. NOTE: The current logic doesn't handle the parsing of memories for DRA7 remoteproc devices, and will be added alongside the DRA7 support. Signed-off-by: Suman Anna <[email protected]> [t-kristo: converted to parse mem names / device addresses from pdata] 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 feae030 commit 4a03219

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

drivers/remoteproc/omap_remoteproc.c

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,58 @@ struct omap_rproc_boot_data {
3939
unsigned int boot_reg;
4040
};
4141

42+
/**
43+
* struct omap_rproc_mem - internal memory structure
44+
* @cpu_addr: MPU virtual address of the memory region
45+
* @bus_addr: bus address used to access the memory region
46+
* @dev_addr: device address of the memory region from DSP view
47+
* @size: size of the memory region
48+
*/
49+
struct omap_rproc_mem {
50+
void __iomem *cpu_addr;
51+
phys_addr_t bus_addr;
52+
u32 dev_addr;
53+
size_t size;
54+
};
55+
4256
/**
4357
* struct omap_rproc - omap remote processor state
4458
* @mbox: mailbox channel handle
4559
* @client: mailbox client to request the mailbox channel
4660
* @boot_data: boot data structure for setting processor boot address
61+
* @mem: internal memory regions data
62+
* @num_mems: number of internal memory regions
4763
* @rproc: rproc handle
4864
* @reset: reset handle
4965
*/
5066
struct omap_rproc {
5167
struct mbox_chan *mbox;
5268
struct mbox_client client;
5369
struct omap_rproc_boot_data *boot_data;
70+
struct omap_rproc_mem *mem;
71+
int num_mems;
5472
struct rproc *rproc;
5573
struct reset_control *reset;
5674
};
5775

76+
/**
77+
* struct omap_rproc_mem_data - memory definitions for an omap remote processor
78+
* @name: name for this memory entry
79+
* @dev_addr: device address for the memory entry
80+
*/
81+
struct omap_rproc_mem_data {
82+
const char *name;
83+
const u32 dev_addr;
84+
};
85+
5886
/**
5987
* struct omap_rproc_dev_data - device data for the omap remote processor
6088
* @device_name: device name of the remote processor
89+
* @mems: memory definitions for this remote processor
6190
*/
6291
struct omap_rproc_dev_data {
6392
const char *device_name;
93+
const struct omap_rproc_mem_data *mems;
6494
};
6595

6696
/**
@@ -221,12 +251,18 @@ static const struct rproc_ops omap_rproc_ops = {
221251
.kick = omap_rproc_kick,
222252
};
223253

254+
static const struct omap_rproc_mem_data ipu_mems[] = {
255+
{ .name = "l2ram", .dev_addr = 0x20000000 },
256+
{ },
257+
};
258+
224259
static const struct omap_rproc_dev_data omap4_dsp_dev_data = {
225260
.device_name = "dsp",
226261
};
227262

228263
static const struct omap_rproc_dev_data omap4_ipu_dev_data = {
229264
.device_name = "ipu",
265+
.mems = ipu_mems,
230266
};
231267

232268
static const struct omap_rproc_dev_data omap5_dsp_dev_data = {
@@ -235,6 +271,7 @@ static const struct omap_rproc_dev_data omap5_dsp_dev_data = {
235271

236272
static const struct omap_rproc_dev_data omap5_ipu_dev_data = {
237273
.device_name = "ipu",
274+
.mems = ipu_mems,
238275
};
239276

240277
static const struct of_device_id omap_rproc_of_match[] = {
@@ -309,6 +346,59 @@ static int omap_rproc_get_boot_data(struct platform_device *pdev,
309346
return 0;
310347
}
311348

349+
static int omap_rproc_of_get_internal_memories(struct platform_device *pdev,
350+
struct rproc *rproc)
351+
{
352+
struct omap_rproc *oproc = rproc->priv;
353+
struct device *dev = &pdev->dev;
354+
const struct omap_rproc_dev_data *data;
355+
struct resource *res;
356+
int num_mems;
357+
int i;
358+
359+
data = of_device_get_match_data(dev);
360+
if (!data)
361+
return -ENODEV;
362+
363+
if (!data->mems)
364+
return 0;
365+
366+
num_mems = of_property_count_elems_of_size(dev->of_node, "reg",
367+
sizeof(u32)) / 2;
368+
369+
oproc->mem = devm_kcalloc(dev, num_mems, sizeof(*oproc->mem),
370+
GFP_KERNEL);
371+
if (!oproc->mem)
372+
return -ENOMEM;
373+
374+
for (i = 0; data->mems[i].name; i++) {
375+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
376+
data->mems[i].name);
377+
if (!res) {
378+
dev_err(dev, "no memory defined for %s\n",
379+
data->mems[i].name);
380+
return -ENOMEM;
381+
}
382+
oproc->mem[i].cpu_addr = devm_ioremap_resource(dev, res);
383+
if (IS_ERR(oproc->mem[i].cpu_addr)) {
384+
dev_err(dev, "failed to parse and map %s memory\n",
385+
data->mems[i].name);
386+
return PTR_ERR(oproc->mem[i].cpu_addr);
387+
}
388+
oproc->mem[i].bus_addr = res->start;
389+
oproc->mem[i].dev_addr = data->mems[i].dev_addr;
390+
oproc->mem[i].size = resource_size(res);
391+
392+
dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %pK da 0x%x\n",
393+
data->mems[i].name, &oproc->mem[i].bus_addr,
394+
oproc->mem[i].size, oproc->mem[i].cpu_addr,
395+
oproc->mem[i].dev_addr);
396+
}
397+
oproc->num_mems = num_mems;
398+
399+
return 0;
400+
}
401+
312402
static int omap_rproc_probe(struct platform_device *pdev)
313403
{
314404
struct device_node *np = pdev->dev.of_node;
@@ -348,6 +438,10 @@ static int omap_rproc_probe(struct platform_device *pdev)
348438
/* All existing OMAP IPU and DSP processors have an MMU */
349439
rproc->has_iommu = true;
350440

441+
ret = omap_rproc_of_get_internal_memories(pdev, rproc);
442+
if (ret)
443+
goto free_rproc;
444+
351445
ret = omap_rproc_get_boot_data(pdev, rproc);
352446
if (ret)
353447
goto free_rproc;

0 commit comments

Comments
 (0)