Commit 5a1a3b9c authored by Linus Walleij's avatar Linus Walleij Committed by Vinod Koul

dmaengine: ste_dma40: Get LCPA SRAM from SRAM node

Instead of passing the reserved SRAM as a "reg" field
look for a phandle to the LCPA SRAM memory so we can
use the proper SRAM device tree bindings for the SRAM.
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230417-ux500-dma40-cleanup-v3-2-60bfa6785968@linaro.orgSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 4f080c77
...@@ -553,6 +553,7 @@ config STE_DMA40 ...@@ -553,6 +553,7 @@ config STE_DMA40
bool "ST-Ericsson DMA40 support" bool "ST-Ericsson DMA40 support"
depends on ARCH_U8500 depends on ARCH_U8500
select DMA_ENGINE select DMA_ENGINE
select SRAM
help help
Support for ST-Ericsson DMA40 controller Support for ST-Ericsson DMA40 controller
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_dma.h> #include <linux/of_dma.h>
#include <linux/amba/bus.h> #include <linux/amba/bus.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
...@@ -3506,9 +3507,11 @@ static int __init d40_probe(struct platform_device *pdev) ...@@ -3506,9 +3507,11 @@ static int __init d40_probe(struct platform_device *pdev)
{ {
struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev); struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev);
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct device_node *np_lcpa;
int ret = -ENOENT; int ret = -ENOENT;
struct d40_base *base; struct d40_base *base;
struct resource *res; struct resource *res;
struct resource res_lcpa;
int num_reserved_chans; int num_reserved_chans;
u32 val; u32 val;
...@@ -3535,37 +3538,37 @@ static int __init d40_probe(struct platform_device *pdev) ...@@ -3535,37 +3538,37 @@ static int __init d40_probe(struct platform_device *pdev)
spin_lock_init(&base->interrupt_lock); spin_lock_init(&base->interrupt_lock);
spin_lock_init(&base->execmd_lock); spin_lock_init(&base->execmd_lock);
/* Get IO for logical channel parameter address */ /* Get IO for logical channel parameter address (LCPA) */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lcpa"); np_lcpa = of_parse_phandle(np, "sram", 0);
if (!res) { if (!np_lcpa) {
ret = -ENOENT; dev_err(&pdev->dev, "no LCPA SRAM node\n");
d40_err(&pdev->dev, "No \"lcpa\" memory resource\n"); goto report_failure;
goto destroy_cache;
} }
base->lcpa_size = resource_size(res); /* This is no device so read the address directly from the node */
base->phy_lcpa = res->start; ret = of_address_to_resource(np_lcpa, 0, &res_lcpa);
if (ret) {
if (request_mem_region(res->start, resource_size(res), dev_err(&pdev->dev, "no LCPA SRAM resource\n");
D40_NAME " I/O lcpa") == NULL) { goto report_failure;
ret = -EBUSY;
d40_err(&pdev->dev, "Failed to request LCPA region %pR\n", res);
goto destroy_cache;
} }
base->lcpa_size = resource_size(&res_lcpa);
base->phy_lcpa = res_lcpa.start;
dev_info(&pdev->dev, "found LCPA SRAM at 0x%08x, size 0x%08x\n",
(u32)base->phy_lcpa, base->lcpa_size);
/* We make use of ESRAM memory for this. */ /* We make use of ESRAM memory for this. */
val = readl(base->virtbase + D40_DREG_LCPA); val = readl(base->virtbase + D40_DREG_LCPA);
if (res->start != val && val != 0) { if (base->phy_lcpa != val && val != 0) {
dev_warn(&pdev->dev, dev_warn(&pdev->dev,
"[%s] Mismatch LCPA dma 0x%x, def %pa\n", "[%s] Mismatch LCPA dma 0x%x, def %08x\n",
__func__, val, &res->start); __func__, val, (u32)base->phy_lcpa);
} else } else
writel(res->start, base->virtbase + D40_DREG_LCPA); writel(base->phy_lcpa, base->virtbase + D40_DREG_LCPA);
base->lcpa_base = ioremap(res->start, resource_size(res)); base->lcpa_base = ioremap(base->phy_lcpa, base->lcpa_size);
if (!base->lcpa_base) { if (!base->lcpa_base) {
ret = -ENOMEM; ret = -ENOMEM;
d40_err(&pdev->dev, "Failed to ioremap LCPA region\n"); d40_err(&pdev->dev, "Failed to ioremap LCPA region\n");
goto destroy_cache; goto release_base;
} }
/* If lcla has to be located in ESRAM we don't need to allocate */ /* If lcla has to be located in ESRAM we don't need to allocate */
if (base->plat_data->use_esram_lcla) { if (base->plat_data->use_esram_lcla) {
...@@ -3678,9 +3681,7 @@ static int __init d40_probe(struct platform_device *pdev) ...@@ -3678,9 +3681,7 @@ static int __init d40_probe(struct platform_device *pdev)
if (base->lcpa_base) if (base->lcpa_base)
iounmap(base->lcpa_base); iounmap(base->lcpa_base);
if (base->phy_lcpa) release_base:
release_mem_region(base->phy_lcpa,
base->lcpa_size);
if (base->phy_start) if (base->phy_start)
release_mem_region(base->phy_start, release_mem_region(base->phy_start,
base->phy_size); base->phy_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment