The ti_k3_m4_remoteproc.c driver previously hardcoded device memory region addresses and names. Change this to use the k3_rproc_mem_data structure to store memory information. This aligns with ti_k3_dsp_remoteproc.c driver, and can be refactored out later. Signed-off-by: Beleswar Padhi <b-padhi@xxxxxx> --- drivers/remoteproc/ti_k3_m4_remoteproc.c | 40 ++++++++++++++++-------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 953c3999019f..fc688b124a54 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,9 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -#define K3_M4_IRAM_DEV_ADDR 0x00000 -#define K3_M4_DRAM_DEV_ADDR 0x30000 - static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc) { struct device *dev = kproc->dev; @@ -210,14 +207,13 @@ static void *k3_m4_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool static int k3_m4_rproc_of_get_memories(struct platform_device *pdev, struct k3_rproc *kproc) { - static const char * const mem_names[] = { "iram", "dram" }; - static const u32 mem_addrs[] = { K3_M4_IRAM_DEV_ADDR, K3_M4_DRAM_DEV_ADDR }; + const struct k3_rproc_dev_data *data = kproc->data; struct device *dev = &pdev->dev; struct resource *res; int num_mems; int i; - num_mems = ARRAY_SIZE(mem_names); + num_mems = kproc->data->num_mems; kproc->mem = devm_kcalloc(kproc->dev, num_mems, sizeof(*kproc->mem), GFP_KERNEL); if (!kproc->mem) @@ -225,17 +221,17 @@ static int k3_m4_rproc_of_get_memories(struct platform_device *pdev, for (i = 0; i < num_mems; i++) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, - mem_names[i]); + data->mems[i].name); if (!res) { dev_err(dev, "found no memory resource for %s\n", - mem_names[i]); + data->mems[i].name); return -EINVAL; } if (!devm_request_mem_region(dev, res->start, resource_size(res), dev_name(dev))) { dev_err(dev, "could not request %s region for resource\n", - mem_names[i]); + data->mems[i].name); return -EBUSY; } @@ -243,15 +239,15 @@ static int k3_m4_rproc_of_get_memories(struct platform_device *pdev, resource_size(res)); if (!kproc->mem[i].cpu_addr) { dev_err(dev, "failed to map %s memory\n", - mem_names[i]); + data->mems[i].name); return -ENOMEM; } kproc->mem[i].bus_addr = res->start; - kproc->mem[i].dev_addr = mem_addrs[i]; + kproc->mem[i].dev_addr = data->mems[i].dev_addr; kproc->mem[i].size = resource_size(res); dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %pK da 0x%x\n", - mem_names[i], &kproc->mem[i].bus_addr, + data->mems[i].name, &kproc->mem[i].bus_addr, kproc->mem[i].size, kproc->mem[i].cpu_addr, kproc->mem[i].dev_addr); } @@ -446,6 +442,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { static int k3_m4_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + const struct k3_rproc_dev_data *data; struct k3_rproc *kproc; struct rproc *rproc; const char *fw_name; @@ -453,6 +450,10 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) bool p_state = false; int ret; + data = of_device_get_match_data(dev); + if (!data) + return -ENODEV; + ret = rproc_of_parse_firmware(dev, 0, &fw_name); if (ret) return dev_err_probe(dev, ret, "failed to parse firmware-name property\n"); @@ -467,6 +468,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) kproc = rproc->priv; kproc->rproc = rproc; kproc->dev = dev; + kproc->data = data; platform_set_drvdata(pdev, rproc); kproc->ti_sci = devm_ti_sci_get_by_phandle(dev, "ti,sci"); @@ -534,8 +536,20 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) return 0; } +static const struct k3_rproc_mem_data am64_m4_mems[] = { + { .name = "iram", .dev_addr = 0x0 }, + { .name = "dram", .dev_addr = 0x30000 }, +}; + +static const struct k3_rproc_dev_data am64_m4_data = { + .mems = am64_m4_mems, + .num_mems = ARRAY_SIZE(am64_m4_mems), + .boot_align_addr = SZ_1K, + .uses_lreset = true, +}; + static const struct of_device_id k3_m4_of_match[] = { - { .compatible = "ti,am64-m4fss", }, + { .compatible = "ti,am64-m4fss", .data = &am64_m4_data, }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, k3_m4_of_match); -- 2.34.1