Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ddd4eeca authored by John Crispin's avatar John Crispin Committed by Ralf Baechle
Browse files

MIPS: lantiq: convert dma to platform driver



Add code to make the dma driver load as a platform device from the devicetree.

Signed-off-by: default avatarJohn Crispin <blogic@openwrt.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/3824/


Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 287e3f3f
Loading
Loading
Loading
Loading
+39 −22
Original line number Original line Diff line number Diff line
@@ -19,7 +19,8 @@
#include <linux/platform_device.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/io.h>
#include <linux/dma-mapping.h>
#include <linux/dma-mapping.h>
#include <linux/export.h>
#include <linux/module.h>
#include <linux/clk.h>


#include <lantiq_soc.h>
#include <lantiq_soc.h>
#include <xway_dma.h>
#include <xway_dma.h>
@@ -55,13 +56,6 @@
#define ltq_dma_w32_mask(x, y, z)	ltq_w32_mask(x, y, \
#define ltq_dma_w32_mask(x, y, z)	ltq_w32_mask(x, y, \
						ltq_dma_membase + (z))
						ltq_dma_membase + (z))


static struct resource ltq_dma_resource = {
	.name	= "dma",
	.start	= LTQ_DMA_BASE_ADDR,
	.end	= LTQ_DMA_BASE_ADDR + LTQ_DMA_SIZE - 1,
	.flags  = IORESOURCE_MEM,
};

static void __iomem *ltq_dma_membase;
static void __iomem *ltq_dma_membase;


void
void
@@ -215,27 +209,28 @@ ltq_dma_init_port(int p)
}
}
EXPORT_SYMBOL_GPL(ltq_dma_init_port);
EXPORT_SYMBOL_GPL(ltq_dma_init_port);


int __init
static int __devinit
ltq_dma_init(void)
ltq_dma_init(struct platform_device *pdev)
{
{
	struct clk *clk;
	struct resource *res;
	int i;
	int i;


	/* insert and request the memory region */
	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (insert_resource(&iomem_resource, &ltq_dma_resource) < 0)
	if (!res)
		panic("Failed to insert dma memory");
		panic("Failed to get dma resource");

	if (request_mem_region(ltq_dma_resource.start,
			resource_size(&ltq_dma_resource), "dma") < 0)
		panic("Failed to request dma memory");


	/* remap dma register range */
	/* remap dma register range */
	ltq_dma_membase = ioremap_nocache(ltq_dma_resource.start,
	ltq_dma_membase = devm_request_and_ioremap(&pdev->dev, res);
				resource_size(&ltq_dma_resource));
	if (!ltq_dma_membase)
	if (!ltq_dma_membase)
		panic("Failed to remap dma memory");
		panic("Failed to remap dma resource");


	/* power up and reset the dma engine */
	/* power up and reset the dma engine */
	ltq_pmu_enable(PMU_DMA);
	clk = clk_get(&pdev->dev, NULL);
	if (IS_ERR(clk))
		panic("Failed to get dma clock");

	clk_enable(clk);
	ltq_dma_w32_mask(0, DMA_RESET, LTQ_DMA_CTRL);
	ltq_dma_w32_mask(0, DMA_RESET, LTQ_DMA_CTRL);


	/* disable all interrupts */
	/* disable all interrupts */
@@ -248,7 +243,29 @@ ltq_dma_init(void)
		ltq_dma_w32(DMA_POLL | DMA_CLK_DIV4, LTQ_DMA_CPOLL);
		ltq_dma_w32(DMA_POLL | DMA_CLK_DIV4, LTQ_DMA_CPOLL);
		ltq_dma_w32_mask(DMA_CHAN_ON, 0, LTQ_DMA_CCTRL);
		ltq_dma_w32_mask(DMA_CHAN_ON, 0, LTQ_DMA_CCTRL);
	}
	}
	dev_info(&pdev->dev, "init done\n");
	return 0;
	return 0;
}
}


postcore_initcall(ltq_dma_init);
static const struct of_device_id dma_match[] = {
	{ .compatible = "lantiq,dma-xway" },
	{},
};
MODULE_DEVICE_TABLE(of, dma_match);

static struct platform_driver dma_driver = {
	.probe = ltq_dma_init,
	.driver = {
		.name = "dma-xway",
		.owner = THIS_MODULE,
		.of_match_table = dma_match,
	},
};

int __init
dma_init(void)
{
	return platform_driver_register(&dma_driver);
}

postcore_initcall(dma_init);