Skip to content

Commit 5a1a3b9

Browse files
Linus Walleijvinodkoul
authored andcommitted
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: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20230417-ux500-dma40-cleanup-v3-2-60bfa6785968@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 4f080c7 commit 5a1a3b9

2 files changed

Lines changed: 25 additions & 23 deletions

File tree

drivers/dma/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ config STE_DMA40
553553
bool "ST-Ericsson DMA40 support"
554554
depends on ARCH_U8500
555555
select DMA_ENGINE
556+
select SRAM
556557
help
557558
Support for ST-Ericsson DMA40 controller
558559

drivers/dma/ste_dma40.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/pm_runtime.h>
2020
#include <linux/err.h>
2121
#include <linux/of.h>
22+
#include <linux/of_address.h>
2223
#include <linux/of_dma.h>
2324
#include <linux/amba/bus.h>
2425
#include <linux/regulator/consumer.h>
@@ -3506,9 +3507,11 @@ static int __init d40_probe(struct platform_device *pdev)
35063507
{
35073508
struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev);
35083509
struct device_node *np = pdev->dev.of_node;
3510+
struct device_node *np_lcpa;
35093511
int ret = -ENOENT;
35103512
struct d40_base *base;
35113513
struct resource *res;
3514+
struct resource res_lcpa;
35123515
int num_reserved_chans;
35133516
u32 val;
35143517

@@ -3535,37 +3538,37 @@ static int __init d40_probe(struct platform_device *pdev)
35353538
spin_lock_init(&base->interrupt_lock);
35363539
spin_lock_init(&base->execmd_lock);
35373540

3538-
/* Get IO for logical channel parameter address */
3539-
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lcpa");
3540-
if (!res) {
3541-
ret = -ENOENT;
3542-
d40_err(&pdev->dev, "No \"lcpa\" memory resource\n");
3543-
goto destroy_cache;
3541+
/* Get IO for logical channel parameter address (LCPA) */
3542+
np_lcpa = of_parse_phandle(np, "sram", 0);
3543+
if (!np_lcpa) {
3544+
dev_err(&pdev->dev, "no LCPA SRAM node\n");
3545+
goto report_failure;
35443546
}
3545-
base->lcpa_size = resource_size(res);
3546-
base->phy_lcpa = res->start;
3547-
3548-
if (request_mem_region(res->start, resource_size(res),
3549-
D40_NAME " I/O lcpa") == NULL) {
3550-
ret = -EBUSY;
3551-
d40_err(&pdev->dev, "Failed to request LCPA region %pR\n", res);
3552-
goto destroy_cache;
3547+
/* This is no device so read the address directly from the node */
3548+
ret = of_address_to_resource(np_lcpa, 0, &res_lcpa);
3549+
if (ret) {
3550+
dev_err(&pdev->dev, "no LCPA SRAM resource\n");
3551+
goto report_failure;
35533552
}
3553+
base->lcpa_size = resource_size(&res_lcpa);
3554+
base->phy_lcpa = res_lcpa.start;
3555+
dev_info(&pdev->dev, "found LCPA SRAM at 0x%08x, size 0x%08x\n",
3556+
(u32)base->phy_lcpa, base->lcpa_size);
35543557

35553558
/* We make use of ESRAM memory for this. */
35563559
val = readl(base->virtbase + D40_DREG_LCPA);
3557-
if (res->start != val && val != 0) {
3560+
if (base->phy_lcpa != val && val != 0) {
35583561
dev_warn(&pdev->dev,
3559-
"[%s] Mismatch LCPA dma 0x%x, def %pa\n",
3560-
__func__, val, &res->start);
3562+
"[%s] Mismatch LCPA dma 0x%x, def %08x\n",
3563+
__func__, val, (u32)base->phy_lcpa);
35613564
} else
3562-
writel(res->start, base->virtbase + D40_DREG_LCPA);
3565+
writel(base->phy_lcpa, base->virtbase + D40_DREG_LCPA);
35633566

3564-
base->lcpa_base = ioremap(res->start, resource_size(res));
3567+
base->lcpa_base = ioremap(base->phy_lcpa, base->lcpa_size);
35653568
if (!base->lcpa_base) {
35663569
ret = -ENOMEM;
35673570
d40_err(&pdev->dev, "Failed to ioremap LCPA region\n");
3568-
goto destroy_cache;
3571+
goto release_base;
35693572
}
35703573
/* If lcla has to be located in ESRAM we don't need to allocate */
35713574
if (base->plat_data->use_esram_lcla) {
@@ -3678,9 +3681,7 @@ static int __init d40_probe(struct platform_device *pdev)
36783681
if (base->lcpa_base)
36793682
iounmap(base->lcpa_base);
36803683

3681-
if (base->phy_lcpa)
3682-
release_mem_region(base->phy_lcpa,
3683-
base->lcpa_size);
3684+
release_base:
36843685
if (base->phy_start)
36853686
release_mem_region(base->phy_start,
36863687
base->phy_size);

0 commit comments

Comments
 (0)