From: hhb <hhb@rock-chips.com>
Date: Fri, 10 Feb 2012 07:09:52 +0000 (+0800)
Subject: rk30:DMA:add driver for dma pl330
X-Git-Tag: firefly_0821_release~9595^2~157
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f3a89a0461df0660a129d8928e01699ea533c1e6;p=firefly-linux-kernel-4.4.55.git

rk30:DMA:add driver for dma pl330
---

diff --git a/arch/arm/common/pl330.c b/arch/arm/common/pl330.c
index c322fe55cc70..e510a75dd222 100644
--- a/arch/arm/common/pl330.c
+++ b/arch/arm/common/pl330.c
@@ -378,10 +378,17 @@ static inline u32 get_id(struct pl330_info *pi, u32 off)
 	void __iomem *regs = pi->base;
 	u32 id = 0;
 
+#ifdef CONFIG_ARCH_RK30
+	id |= ((readl(regs + off + 0x0) & 0xff) << 0);
+	id |= ((readl(regs + off + 0x4) & 0xff)<< 8);
+	id |= ((readl(regs + off + 0x8) & 0xff) << 16);
+	id |= ((readl(regs + off + 0xc) & 0xff)<< 24);
+#else
 	id |= (readb(regs + off + 0x0) << 0);
 	id |= (readb(regs + off + 0x4) << 8);
 	id |= (readb(regs + off + 0x8) << 16);
 	id |= (readb(regs + off + 0xc) << 24);
+#endif
 
 	return id;
 }
diff --git a/arch/arm/mach-rk30/devices.c b/arch/arm/mach-rk30/devices.c
index 45d9ceb9f487..7b21a4606ee5 100644
--- a/arch/arm/mach-rk30/devices.c
+++ b/arch/arm/mach-rk30/devices.c
@@ -21,6 +21,143 @@
 #include <asm/pmu.h>
 #include <mach/irqs.h>
 #include <mach/board.h>
+#include <mach/dma-pl330.h>
+
+static u64 dma_dmamask = DMA_BIT_MASK(32);
+
+static struct resource resource_dmac1[] = {
+	[0] = {
+		.start  = RK30_DMACS1_PHYS,
+		.end    = RK30_DMACS1_PHYS + RK30_DMACS1_SIZE -1,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= IRQ_DMAC1_0,
+		.end	= IRQ_DMAC1_1,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct rk29_pl330_platdata dmac1_pdata = {
+	.peri = {
+		[0] = DMACH_UART0_TX,
+		[1] = DMACH_UART0_RX,
+		[2] = DMACH_UART1_TX,
+		[3] = DMACH_UART1_RX,
+		[4] = DMACH_I2S0_8CH_TX,
+		[5] = DMACH_I2S0_8CH_RX,
+		[6] = DMACH_I2S1_2CH_TX,
+		[7] = DMACH_I2S1_2CH_RX,
+		[8] = DMACH_SPDIF_TX,
+		[9] = DMACH_I2S2_2CH_TX,
+		[10] = DMACH_I2S2_2CH_RX,
+		[11] = DMACH_MAX,
+		[12] = DMACH_MAX,
+		[13] = DMACH_MAX,
+		[14] = DMACH_MAX,
+		[15] = DMACH_MAX,
+		[16] = DMACH_MAX,
+		[17] = DMACH_MAX,
+		[18] = DMACH_MAX,
+		[19] = DMACH_MAX,
+		[20] = DMACH_MAX,
+		[21] = DMACH_MAX,
+		[22] = DMACH_MAX,
+		[23] = DMACH_MAX,
+		[24] = DMACH_MAX,
+		[25] = DMACH_MAX,
+		[26] = DMACH_MAX,
+		[27] = DMACH_MAX,
+		[28] = DMACH_MAX,
+		[29] = DMACH_MAX,
+		[30] = DMACH_MAX,
+		[31] = DMACH_MAX,
+	},
+};
+
+static struct platform_device device_dmac1 = {
+	.name		= "rk29-pl330",
+	.id		= 1,
+	.num_resources	= ARRAY_SIZE(resource_dmac1),
+	.resource	= resource_dmac1,
+	.dev		= {
+		.dma_mask = &dma_dmamask,
+		.coherent_dma_mask = DMA_BIT_MASK(32),
+		.platform_data = &dmac1_pdata,
+	},
+};
+
+static struct resource resource_dmac2[] = {
+	[0] = {
+		.start  = RK30_DMAC2_PHYS,
+		.end    = RK30_DMAC2_PHYS + RK30_DMAC2_SIZE - 1,
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= IRQ_DMAC2_0,
+		.end	= IRQ_DMAC2_1,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct rk29_pl330_platdata dmac2_pdata = {
+	.peri = {
+		[0] = DMACH_HSADC,
+		[1] = DMACH_SDMMC,
+		[2] = DMACH_MAX,
+		[3] = DMACH_SDIO,
+		[4] = DMACH_EMMC,
+		[5] = DMACH_PID_FILTER,
+		[6] = DMACH_UART2_TX,
+		[7] = DMACH_UART2_RX,
+		[8] = DMACH_UART3_TX,
+		[9] = DMACH_UART3_RX,
+		[10] = DMACH_SPI0_TX,
+		[11] = DMACH_SPI0_RX,
+		[12] = DMACH_SPI1_TX,
+		[13] = DMACH_SPI1_RX,
+		[14] = DMACH_DMAC2_MEMTOMEM,
+		[15] = DMACH_MAX,
+		[16] = DMACH_MAX,
+		[17] = DMACH_MAX,
+		[18] = DMACH_MAX,
+		[19] = DMACH_MAX,
+		[20] = DMACH_MAX,
+		[21] = DMACH_MAX,
+		[22] = DMACH_MAX,
+		[23] = DMACH_MAX,
+		[24] = DMACH_MAX,
+		[25] = DMACH_MAX,
+		[26] = DMACH_MAX,
+		[27] = DMACH_MAX,
+		[28] = DMACH_MAX,
+		[29] = DMACH_MAX,
+		[30] = DMACH_MAX,
+		[31] = DMACH_MAX,
+	},
+};
+
+static struct platform_device device_dmac2 = {
+	.name		= "rk29-pl330",
+	.id		= 2,
+	.num_resources	= ARRAY_SIZE(resource_dmac2),
+	.resource	= resource_dmac2,
+	.dev		= {
+		.dma_mask = &dma_dmamask,
+		.coherent_dma_mask = DMA_BIT_MASK(32),
+		.platform_data = &dmac2_pdata,
+	},
+};
+
+static struct platform_device *rk30_dmacs[] __initdata = {
+	&device_dmac1,
+	&device_dmac2,
+};
+
+static void __init rk30_init_dma(void)
+{
+	platform_add_devices(rk30_dmacs, ARRAY_SIZE(rk30_dmacs));
+}
 
 #ifdef CONFIG_UART0_RK29
 static struct resource resources_uart0[] = {
@@ -355,6 +492,7 @@ static struct platform_device device_keys = {
 #endif
 static int __init rk30_init_devices(void)
 {
+	rk30_init_dma();
 	rk30_init_uart();
 	rk30_init_i2c();
 #ifdef CONFIG_MTD_NAND_RK29XX
diff --git a/arch/arm/plat-rk/Makefile b/arch/arm/plat-rk/Makefile
index b7e7502ac913..f78a8e5a60cb 100644
--- a/arch/arm/plat-rk/Makefile
+++ b/arch/arm/plat-rk/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_RK29_LAST_LOG) += last_log.o
 obj-$(CONFIG_USB_GADGET) += usb_detect.o
 obj-$(CONFIG_RK29_VPU) += vpu_service.o
+obj-$(CONFIG_ARCH_RK30) += dma-pl330.o
 obj-y += mem_reserve.o