xref: /openbmc/linux/arch/arm/mach-omap1/dma.c (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
26568f7c4SG, Manjunath Kondaiah /*
36568f7c4SG, Manjunath Kondaiah  * OMAP1/OMAP7xx - specific DMA driver
46568f7c4SG, Manjunath Kondaiah  *
56568f7c4SG, Manjunath Kondaiah  * Copyright (C) 2003 - 2008 Nokia Corporation
66568f7c4SG, Manjunath Kondaiah  * Author: Juha Yrjölä <juha.yrjola@nokia.com>
76568f7c4SG, Manjunath Kondaiah  * DMA channel linking for 1610 by Samuel Ortiz <samuel.ortiz@nokia.com>
86568f7c4SG, Manjunath Kondaiah  * Graphics DMA and LCD DMA graphics tranformations
96568f7c4SG, Manjunath Kondaiah  * by Imre Deak <imre.deak@nokia.com>
106568f7c4SG, Manjunath Kondaiah  * OMAP2/3 support Copyright (C) 2004-2007 Texas Instruments, Inc.
116568f7c4SG, Manjunath Kondaiah  * Some functions based on earlier dma-omap.c Copyright (C) 2001 RidgeRun, Inc.
126568f7c4SG, Manjunath Kondaiah  *
13e9dbebafSAlexander A. Klimov  * Copyright (C) 2010 Texas Instruments Incorporated - https://www.ti.com/
146568f7c4SG, Manjunath Kondaiah  * Converted DMA library into platform driver
156568f7c4SG, Manjunath Kondaiah  *                   - G, Manjunath Kondaiah <manjugk@ti.com>
166568f7c4SG, Manjunath Kondaiah  */
176568f7c4SG, Manjunath Kondaiah 
186568f7c4SG, Manjunath Kondaiah #include <linux/err.h>
196568f7c4SG, Manjunath Kondaiah #include <linux/slab.h>
206568f7c4SG, Manjunath Kondaiah #include <linux/module.h>
216568f7c4SG, Manjunath Kondaiah #include <linux/init.h>
226568f7c4SG, Manjunath Kondaiah #include <linux/device.h>
232e3ee9f4STony Lindgren #include <linux/io.h>
24be1f9481STony Lindgren #include <linux/dma-mapping.h>
25c4e35783SPeter Ujfalusi #include <linux/dmaengine.h>
2645c3eb7dSTony Lindgren #include <linux/omap-dma.h>
27*7e0a9e62SArnd Bergmann #include "tc.h"
288afc5e08STony Lindgren 
29685e2d08STony Lindgren #include "soc.h"
306568f7c4SG, Manjunath Kondaiah 
316568f7c4SG, Manjunath Kondaiah #define OMAP1_DMA_BASE			(0xfffed800)
32f31cc962SG, Manjunath Kondaiah 
33f31cc962SG, Manjunath Kondaiah static u32 enable_1510_mode;
34f31cc962SG, Manjunath Kondaiah 
3564a2dc3dSRussell King static const struct omap_dma_reg reg_map[] = {
3664a2dc3dSRussell King 	[GCR]		= { 0x0400, 0x00, OMAP_DMA_REG_16BIT },
3764a2dc3dSRussell King 	[GSCR]		= { 0x0404, 0x00, OMAP_DMA_REG_16BIT },
3864a2dc3dSRussell King 	[GRST1]		= { 0x0408, 0x00, OMAP_DMA_REG_16BIT },
3964a2dc3dSRussell King 	[HW_ID]		= { 0x0442, 0x00, OMAP_DMA_REG_16BIT },
4064a2dc3dSRussell King 	[PCH2_ID]	= { 0x0444, 0x00, OMAP_DMA_REG_16BIT },
4164a2dc3dSRussell King 	[PCH0_ID]	= { 0x0446, 0x00, OMAP_DMA_REG_16BIT },
4264a2dc3dSRussell King 	[PCH1_ID]	= { 0x0448, 0x00, OMAP_DMA_REG_16BIT },
4364a2dc3dSRussell King 	[PCHG_ID]	= { 0x044a, 0x00, OMAP_DMA_REG_16BIT },
4464a2dc3dSRussell King 	[PCHD_ID]	= { 0x044c, 0x00, OMAP_DMA_REG_16BIT },
4564a2dc3dSRussell King 	[CAPS_0]	= { 0x044e, 0x00, OMAP_DMA_REG_2X16BIT },
4664a2dc3dSRussell King 	[CAPS_1]	= { 0x0452, 0x00, OMAP_DMA_REG_2X16BIT },
4764a2dc3dSRussell King 	[CAPS_2]	= { 0x0456, 0x00, OMAP_DMA_REG_16BIT },
4864a2dc3dSRussell King 	[CAPS_3]	= { 0x0458, 0x00, OMAP_DMA_REG_16BIT },
4964a2dc3dSRussell King 	[CAPS_4]	= { 0x045a, 0x00, OMAP_DMA_REG_16BIT },
5064a2dc3dSRussell King 	[PCH2_SR]	= { 0x0460, 0x00, OMAP_DMA_REG_16BIT },
5164a2dc3dSRussell King 	[PCH0_SR]	= { 0x0480, 0x00, OMAP_DMA_REG_16BIT },
5264a2dc3dSRussell King 	[PCH1_SR]	= { 0x0482, 0x00, OMAP_DMA_REG_16BIT },
5364a2dc3dSRussell King 	[PCHD_SR]	= { 0x04c0, 0x00, OMAP_DMA_REG_16BIT },
54f31cc962SG, Manjunath Kondaiah 
55f31cc962SG, Manjunath Kondaiah 	/* Common Registers */
5664a2dc3dSRussell King 	[CSDP]		= { 0x0000, 0x40, OMAP_DMA_REG_16BIT },
5764a2dc3dSRussell King 	[CCR]		= { 0x0002, 0x40, OMAP_DMA_REG_16BIT },
5864a2dc3dSRussell King 	[CICR]		= { 0x0004, 0x40, OMAP_DMA_REG_16BIT },
5964a2dc3dSRussell King 	[CSR]		= { 0x0006, 0x40, OMAP_DMA_REG_16BIT },
6064a2dc3dSRussell King 	[CEN]		= { 0x0010, 0x40, OMAP_DMA_REG_16BIT },
6164a2dc3dSRussell King 	[CFN]		= { 0x0012, 0x40, OMAP_DMA_REG_16BIT },
6264a2dc3dSRussell King 	[CSFI]		= { 0x0014, 0x40, OMAP_DMA_REG_16BIT },
6364a2dc3dSRussell King 	[CSEI]		= { 0x0016, 0x40, OMAP_DMA_REG_16BIT },
6464a2dc3dSRussell King 	[CPC]		= { 0x0018, 0x40, OMAP_DMA_REG_16BIT },	/* 15xx only */
6564a2dc3dSRussell King 	[CSAC]		= { 0x0018, 0x40, OMAP_DMA_REG_16BIT },
6664a2dc3dSRussell King 	[CDAC]		= { 0x001a, 0x40, OMAP_DMA_REG_16BIT },
6764a2dc3dSRussell King 	[CDEI]		= { 0x001c, 0x40, OMAP_DMA_REG_16BIT },
6864a2dc3dSRussell King 	[CDFI]		= { 0x001e, 0x40, OMAP_DMA_REG_16BIT },
6964a2dc3dSRussell King 	[CLNK_CTRL]	= { 0x0028, 0x40, OMAP_DMA_REG_16BIT },
70f31cc962SG, Manjunath Kondaiah 
71f31cc962SG, Manjunath Kondaiah 	/* Channel specific register offsets */
7264a2dc3dSRussell King 	[CSSA]		= { 0x0008, 0x40, OMAP_DMA_REG_2X16BIT },
7364a2dc3dSRussell King 	[CDSA]		= { 0x000c, 0x40, OMAP_DMA_REG_2X16BIT },
7464a2dc3dSRussell King 	[COLOR]		= { 0x0020, 0x40, OMAP_DMA_REG_2X16BIT },
7564a2dc3dSRussell King 	[CCR2]		= { 0x0024, 0x40, OMAP_DMA_REG_16BIT },
7664a2dc3dSRussell King 	[LCH_CTRL]	= { 0x002a, 0x40, OMAP_DMA_REG_16BIT },
77f31cc962SG, Manjunath Kondaiah };
786568f7c4SG, Manjunath Kondaiah 
796568f7c4SG, Manjunath Kondaiah static struct resource res[] __initdata = {
806568f7c4SG, Manjunath Kondaiah 	[0] = {
816568f7c4SG, Manjunath Kondaiah 		.start	= OMAP1_DMA_BASE,
826568f7c4SG, Manjunath Kondaiah 		.end	= OMAP1_DMA_BASE + SZ_2K - 1,
836568f7c4SG, Manjunath Kondaiah 		.flags	= IORESOURCE_MEM,
846568f7c4SG, Manjunath Kondaiah 	},
856568f7c4SG, Manjunath Kondaiah 	[1] = {
866568f7c4SG, Manjunath Kondaiah 		.name   = "0",
876568f7c4SG, Manjunath Kondaiah 		.start  = INT_DMA_CH0_6,
886568f7c4SG, Manjunath Kondaiah 		.flags  = IORESOURCE_IRQ,
896568f7c4SG, Manjunath Kondaiah 	},
906568f7c4SG, Manjunath Kondaiah 	[2] = {
916568f7c4SG, Manjunath Kondaiah 		.name   = "1",
926568f7c4SG, Manjunath Kondaiah 		.start  = INT_DMA_CH1_7,
936568f7c4SG, Manjunath Kondaiah 		.flags  = IORESOURCE_IRQ,
946568f7c4SG, Manjunath Kondaiah 	},
956568f7c4SG, Manjunath Kondaiah 	[3] = {
966568f7c4SG, Manjunath Kondaiah 		.name   = "2",
976568f7c4SG, Manjunath Kondaiah 		.start  = INT_DMA_CH2_8,
986568f7c4SG, Manjunath Kondaiah 		.flags  = IORESOURCE_IRQ,
996568f7c4SG, Manjunath Kondaiah 	},
1006568f7c4SG, Manjunath Kondaiah 	[4] = {
1016568f7c4SG, Manjunath Kondaiah 		.name   = "3",
1026568f7c4SG, Manjunath Kondaiah 		.start  = INT_DMA_CH3,
1036568f7c4SG, Manjunath Kondaiah 		.flags  = IORESOURCE_IRQ,
1046568f7c4SG, Manjunath Kondaiah 	},
1056568f7c4SG, Manjunath Kondaiah 	[5] = {
1066568f7c4SG, Manjunath Kondaiah 		.name   = "4",
1076568f7c4SG, Manjunath Kondaiah 		.start  = INT_DMA_CH4,
1086568f7c4SG, Manjunath Kondaiah 		.flags  = IORESOURCE_IRQ,
1096568f7c4SG, Manjunath Kondaiah 	},
1106568f7c4SG, Manjunath Kondaiah 	[6] = {
1116568f7c4SG, Manjunath Kondaiah 		.name   = "5",
1126568f7c4SG, Manjunath Kondaiah 		.start  = INT_DMA_CH5,
1136568f7c4SG, Manjunath Kondaiah 		.flags  = IORESOURCE_IRQ,
1146568f7c4SG, Manjunath Kondaiah 	},
115f31cc962SG, Manjunath Kondaiah 	/* Handled in lcd_dma.c */
1166568f7c4SG, Manjunath Kondaiah 	[7] = {
1176568f7c4SG, Manjunath Kondaiah 		.name   = "6",
1186568f7c4SG, Manjunath Kondaiah 		.start  = INT_1610_DMA_CH6,
1196568f7c4SG, Manjunath Kondaiah 		.flags  = IORESOURCE_IRQ,
1206568f7c4SG, Manjunath Kondaiah 	},
1216568f7c4SG, Manjunath Kondaiah 	/* irq's for omap16xx and omap7xx */
1226568f7c4SG, Manjunath Kondaiah 	[8] = {
1236568f7c4SG, Manjunath Kondaiah 		.name   = "7",
1246568f7c4SG, Manjunath Kondaiah 		.start  = INT_1610_DMA_CH7,
1256568f7c4SG, Manjunath Kondaiah 		.flags  = IORESOURCE_IRQ,
1266568f7c4SG, Manjunath Kondaiah 	},
1276568f7c4SG, Manjunath Kondaiah 	[9] = {
1286568f7c4SG, Manjunath Kondaiah 		.name   = "8",
1296568f7c4SG, Manjunath Kondaiah 		.start  = INT_1610_DMA_CH8,
1306568f7c4SG, Manjunath Kondaiah 		.flags  = IORESOURCE_IRQ,
1316568f7c4SG, Manjunath Kondaiah 	},
1326568f7c4SG, Manjunath Kondaiah 	[10] = {
1336568f7c4SG, Manjunath Kondaiah 		.name  = "9",
1346568f7c4SG, Manjunath Kondaiah 		.start = INT_1610_DMA_CH9,
1356568f7c4SG, Manjunath Kondaiah 		.flags = IORESOURCE_IRQ,
1366568f7c4SG, Manjunath Kondaiah 	},
1376568f7c4SG, Manjunath Kondaiah 	[11] = {
1386568f7c4SG, Manjunath Kondaiah 		.name  = "10",
1396568f7c4SG, Manjunath Kondaiah 		.start = INT_1610_DMA_CH10,
1406568f7c4SG, Manjunath Kondaiah 		.flags = IORESOURCE_IRQ,
1416568f7c4SG, Manjunath Kondaiah 	},
1426568f7c4SG, Manjunath Kondaiah 	[12] = {
1436568f7c4SG, Manjunath Kondaiah 		.name  = "11",
1446568f7c4SG, Manjunath Kondaiah 		.start = INT_1610_DMA_CH11,
1456568f7c4SG, Manjunath Kondaiah 		.flags = IORESOURCE_IRQ,
1466568f7c4SG, Manjunath Kondaiah 	},
1476568f7c4SG, Manjunath Kondaiah 	[13] = {
1486568f7c4SG, Manjunath Kondaiah 		.name  = "12",
1496568f7c4SG, Manjunath Kondaiah 		.start = INT_1610_DMA_CH12,
1506568f7c4SG, Manjunath Kondaiah 		.flags = IORESOURCE_IRQ,
1516568f7c4SG, Manjunath Kondaiah 	},
1526568f7c4SG, Manjunath Kondaiah 	[14] = {
1536568f7c4SG, Manjunath Kondaiah 		.name  = "13",
1546568f7c4SG, Manjunath Kondaiah 		.start = INT_1610_DMA_CH13,
1556568f7c4SG, Manjunath Kondaiah 		.flags = IORESOURCE_IRQ,
1566568f7c4SG, Manjunath Kondaiah 	},
1576568f7c4SG, Manjunath Kondaiah 	[15] = {
1586568f7c4SG, Manjunath Kondaiah 		.name  = "14",
1596568f7c4SG, Manjunath Kondaiah 		.start = INT_1610_DMA_CH14,
1606568f7c4SG, Manjunath Kondaiah 		.flags = IORESOURCE_IRQ,
1616568f7c4SG, Manjunath Kondaiah 	},
1626568f7c4SG, Manjunath Kondaiah 	[16] = {
1636568f7c4SG, Manjunath Kondaiah 		.name  = "15",
1646568f7c4SG, Manjunath Kondaiah 		.start = INT_1610_DMA_CH15,
1656568f7c4SG, Manjunath Kondaiah 		.flags = IORESOURCE_IRQ,
1666568f7c4SG, Manjunath Kondaiah 	},
1676568f7c4SG, Manjunath Kondaiah 	[17] = {
1686568f7c4SG, Manjunath Kondaiah 		.name  = "16",
1696568f7c4SG, Manjunath Kondaiah 		.start = INT_DMA_LCD,
1706568f7c4SG, Manjunath Kondaiah 		.flags = IORESOURCE_IRQ,
1716568f7c4SG, Manjunath Kondaiah 	},
1726568f7c4SG, Manjunath Kondaiah };
1736568f7c4SG, Manjunath Kondaiah 
174f31cc962SG, Manjunath Kondaiah static void __iomem *dma_base;
dma_write(u32 val,int reg,int lch)175f31cc962SG, Manjunath Kondaiah static inline void dma_write(u32 val, int reg, int lch)
176f31cc962SG, Manjunath Kondaiah {
17764a2dc3dSRussell King 	void __iomem *addr = dma_base;
178f31cc962SG, Manjunath Kondaiah 
17964a2dc3dSRussell King 	addr += reg_map[reg].offset;
18064a2dc3dSRussell King 	addr += reg_map[reg].stride * lch;
181f31cc962SG, Manjunath Kondaiah 
18264a2dc3dSRussell King 	__raw_writew(val, addr);
18364a2dc3dSRussell King 	if (reg_map[reg].type == OMAP_DMA_REG_2X16BIT)
18464a2dc3dSRussell King 		__raw_writew(val >> 16, addr + 2);
185f31cc962SG, Manjunath Kondaiah }
186f31cc962SG, Manjunath Kondaiah 
dma_read(int reg,int lch)187f31cc962SG, Manjunath Kondaiah static inline u32 dma_read(int reg, int lch)
188f31cc962SG, Manjunath Kondaiah {
18964a2dc3dSRussell King 	void __iomem *addr = dma_base;
19064a2dc3dSRussell King 	uint32_t val;
191f31cc962SG, Manjunath Kondaiah 
19264a2dc3dSRussell King 	addr += reg_map[reg].offset;
19364a2dc3dSRussell King 	addr += reg_map[reg].stride * lch;
194f31cc962SG, Manjunath Kondaiah 
19564a2dc3dSRussell King 	val = __raw_readw(addr);
19664a2dc3dSRussell King 	if (reg_map[reg].type == OMAP_DMA_REG_2X16BIT)
19764a2dc3dSRussell King 		val |= __raw_readw(addr + 2) << 16;
19864a2dc3dSRussell King 
199f31cc962SG, Manjunath Kondaiah 	return val;
200f31cc962SG, Manjunath Kondaiah }
201f31cc962SG, Manjunath Kondaiah 
omap1_clear_lch_regs(int lch)202f31cc962SG, Manjunath Kondaiah static void omap1_clear_lch_regs(int lch)
203f31cc962SG, Manjunath Kondaiah {
204ad0c381aSRussell King 	int i;
205f31cc962SG, Manjunath Kondaiah 
206ad0c381aSRussell King 	for (i = CPC; i <= COLOR; i += 1)
207f31cc962SG, Manjunath Kondaiah 		dma_write(0, i, lch);
208f31cc962SG, Manjunath Kondaiah }
209f31cc962SG, Manjunath Kondaiah 
omap1_clear_dma(int lch)210f31cc962SG, Manjunath Kondaiah static void omap1_clear_dma(int lch)
211f31cc962SG, Manjunath Kondaiah {
212f31cc962SG, Manjunath Kondaiah 	u32 l;
213f31cc962SG, Manjunath Kondaiah 
214f31cc962SG, Manjunath Kondaiah 	l = dma_read(CCR, lch);
215f31cc962SG, Manjunath Kondaiah 	l &= ~OMAP_DMA_CCR_EN;
216f31cc962SG, Manjunath Kondaiah 	dma_write(l, CCR, lch);
217f31cc962SG, Manjunath Kondaiah 
218f31cc962SG, Manjunath Kondaiah 	/* Clear pending interrupts */
219f31cc962SG, Manjunath Kondaiah 	l = dma_read(CSR, lch);
220f31cc962SG, Manjunath Kondaiah }
221f31cc962SG, Manjunath Kondaiah 
omap1_show_dma_caps(void)222f31cc962SG, Manjunath Kondaiah static void omap1_show_dma_caps(void)
223f31cc962SG, Manjunath Kondaiah {
224f31cc962SG, Manjunath Kondaiah 	if (enable_1510_mode) {
225f31cc962SG, Manjunath Kondaiah 		printk(KERN_INFO "DMA support for OMAP15xx initialized\n");
226f31cc962SG, Manjunath Kondaiah 	} else {
227f31cc962SG, Manjunath Kondaiah 		u16 w;
228f31cc962SG, Manjunath Kondaiah 		printk(KERN_INFO "OMAP DMA hardware version %d\n",
229f31cc962SG, Manjunath Kondaiah 							dma_read(HW_ID, 0));
230f31cc962SG, Manjunath Kondaiah 		printk(KERN_INFO "DMA capabilities: %08x:%08x:%04x:%04x:%04x\n",
231f31cc962SG, Manjunath Kondaiah 			dma_read(CAPS_0, 0), dma_read(CAPS_1, 0),
232f31cc962SG, Manjunath Kondaiah 			dma_read(CAPS_2, 0), dma_read(CAPS_3, 0),
233f31cc962SG, Manjunath Kondaiah 			dma_read(CAPS_4, 0));
234f31cc962SG, Manjunath Kondaiah 
235f31cc962SG, Manjunath Kondaiah 		/* Disable OMAP 3.0/3.1 compatibility mode. */
236f31cc962SG, Manjunath Kondaiah 		w = dma_read(GSCR, 0);
237f31cc962SG, Manjunath Kondaiah 		w |= 1 << 3;
238f31cc962SG, Manjunath Kondaiah 		dma_write(w, GSCR, 0);
239f31cc962SG, Manjunath Kondaiah 	}
240f31cc962SG, Manjunath Kondaiah }
241f31cc962SG, Manjunath Kondaiah 
configure_dma_errata(void)2420ef64986SRussell King static unsigned configure_dma_errata(void)
243f31cc962SG, Manjunath Kondaiah {
2440ef64986SRussell King 	unsigned errata = 0;
245f31cc962SG, Manjunath Kondaiah 
246f31cc962SG, Manjunath Kondaiah 	/*
247f31cc962SG, Manjunath Kondaiah 	 * Erratum 3.2/3.3: sometimes 0 is returned if CSAC/CDAC is
248f31cc962SG, Manjunath Kondaiah 	 * read before the DMA controller finished disabling the channel.
249f31cc962SG, Manjunath Kondaiah 	 */
250f31cc962SG, Manjunath Kondaiah 	if (!cpu_is_omap15xx())
251f31cc962SG, Manjunath Kondaiah 		SET_DMA_ERRATA(DMA_ERRATA_3_3);
252f31cc962SG, Manjunath Kondaiah 
253f31cc962SG, Manjunath Kondaiah 	return errata;
254f31cc962SG, Manjunath Kondaiah }
255f31cc962SG, Manjunath Kondaiah 
256be1f9481STony Lindgren static const struct platform_device_info omap_dma_dev_info = {
257be1f9481STony Lindgren 	.name = "omap-dma-engine",
258be1f9481STony Lindgren 	.id = -1,
259be1f9481STony Lindgren 	.dma_mask = DMA_BIT_MASK(32),
260596c471bSRussell King 	.res = res,
261596c471bSRussell King 	.num_res = 1,
262be1f9481STony Lindgren };
263be1f9481STony Lindgren 
264c4e35783SPeter Ujfalusi /* OMAP1510, OMAP1610*/
265c4e35783SPeter Ujfalusi static const struct dma_slave_map omap1xxx_sdma_map[] = {
266c4e35783SPeter Ujfalusi 	{ "omap-mcbsp.1", "tx", SDMA_FILTER_PARAM(8) },
267c4e35783SPeter Ujfalusi 	{ "omap-mcbsp.1", "rx", SDMA_FILTER_PARAM(9) },
268c4e35783SPeter Ujfalusi 	{ "omap-mcbsp.3", "tx", SDMA_FILTER_PARAM(10) },
269c4e35783SPeter Ujfalusi 	{ "omap-mcbsp.3", "rx", SDMA_FILTER_PARAM(11) },
270c4e35783SPeter Ujfalusi 	{ "omap-mcbsp.2", "tx", SDMA_FILTER_PARAM(16) },
271c4e35783SPeter Ujfalusi 	{ "omap-mcbsp.2", "rx", SDMA_FILTER_PARAM(17) },
272c4e35783SPeter Ujfalusi 	{ "mmci-omap.0", "tx", SDMA_FILTER_PARAM(21) },
273c4e35783SPeter Ujfalusi 	{ "mmci-omap.0", "rx", SDMA_FILTER_PARAM(22) },
274c4e35783SPeter Ujfalusi 	{ "omap_udc", "rx0", SDMA_FILTER_PARAM(26) },
275c4e35783SPeter Ujfalusi 	{ "omap_udc", "rx1", SDMA_FILTER_PARAM(27) },
276c4e35783SPeter Ujfalusi 	{ "omap_udc", "rx2", SDMA_FILTER_PARAM(28) },
277c4e35783SPeter Ujfalusi 	{ "omap_udc", "tx0", SDMA_FILTER_PARAM(29) },
278c4e35783SPeter Ujfalusi 	{ "omap_udc", "tx1", SDMA_FILTER_PARAM(30) },
279c4e35783SPeter Ujfalusi 	{ "omap_udc", "tx2", SDMA_FILTER_PARAM(31) },
280c4e35783SPeter Ujfalusi 	{ "mmci-omap.1", "tx", SDMA_FILTER_PARAM(54) },
281c4e35783SPeter Ujfalusi 	{ "mmci-omap.1", "rx", SDMA_FILTER_PARAM(55) },
282c4e35783SPeter Ujfalusi };
283c4e35783SPeter Ujfalusi 
28434a378fcSRussell King static struct omap_system_dma_plat_info dma_plat_info __initdata = {
285596c471bSRussell King 	.reg_map	= reg_map,
286596c471bSRussell King 	.channel_stride	= 0x40,
28734a378fcSRussell King 	.show_dma_caps	= omap1_show_dma_caps,
28834a378fcSRussell King 	.clear_lch_regs	= omap1_clear_lch_regs,
28934a378fcSRussell King 	.clear_dma	= omap1_clear_dma,
29034a378fcSRussell King 	.dma_write	= dma_write,
29134a378fcSRussell King 	.dma_read	= dma_read,
29234a378fcSRussell King };
29334a378fcSRussell King 
omap1_system_dma_init(void)2946568f7c4SG, Manjunath Kondaiah static int __init omap1_system_dma_init(void)
2956568f7c4SG, Manjunath Kondaiah {
29634a378fcSRussell King 	struct omap_system_dma_plat_info	p;
297f31cc962SG, Manjunath Kondaiah 	struct omap_dma_dev_attr		*d;
298be1f9481STony Lindgren 	struct platform_device			*pdev, *dma_pdev;
2996568f7c4SG, Manjunath Kondaiah 	int ret;
3006568f7c4SG, Manjunath Kondaiah 
3016568f7c4SG, Manjunath Kondaiah 	pdev = platform_device_alloc("omap_dma_system", 0);
3026568f7c4SG, Manjunath Kondaiah 	if (!pdev) {
3036568f7c4SG, Manjunath Kondaiah 		pr_err("%s: Unable to device alloc for dma\n",
3046568f7c4SG, Manjunath Kondaiah 			__func__);
3056568f7c4SG, Manjunath Kondaiah 		return -ENOMEM;
3066568f7c4SG, Manjunath Kondaiah 	}
3076568f7c4SG, Manjunath Kondaiah 
308f31cc962SG, Manjunath Kondaiah 	dma_base = ioremap(res[0].start, resource_size(&res[0]));
309f31cc962SG, Manjunath Kondaiah 	if (!dma_base) {
310f31cc962SG, Manjunath Kondaiah 		pr_err("%s: Unable to ioremap\n", __func__);
31177f7059aSJulia Lawall 		ret = -ENODEV;
31277f7059aSJulia Lawall 		goto exit_device_put;
313f31cc962SG, Manjunath Kondaiah 	}
314f31cc962SG, Manjunath Kondaiah 
3156568f7c4SG, Manjunath Kondaiah 	ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
3166568f7c4SG, Manjunath Kondaiah 	if (ret) {
3176568f7c4SG, Manjunath Kondaiah 		dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n",
3186568f7c4SG, Manjunath Kondaiah 			__func__, pdev->name, pdev->id);
319348c3422SWei Yongjun 		goto exit_iounmap;
3206568f7c4SG, Manjunath Kondaiah 	}
3216568f7c4SG, Manjunath Kondaiah 
322d27a30bbSMarkus Elfring 	d = kzalloc(sizeof(*d), GFP_KERNEL);
323f31cc962SG, Manjunath Kondaiah 	if (!d) {
324f31cc962SG, Manjunath Kondaiah 		ret = -ENOMEM;
32534a378fcSRussell King 		goto exit_iounmap;
326f31cc962SG, Manjunath Kondaiah 	}
327f31cc962SG, Manjunath Kondaiah 
328f31cc962SG, Manjunath Kondaiah 	/* Valid attributes for omap1 plus processors */
329f31cc962SG, Manjunath Kondaiah 	if (cpu_is_omap15xx())
330f31cc962SG, Manjunath Kondaiah 		d->dev_caps = ENABLE_1510_MODE;
331f31cc962SG, Manjunath Kondaiah 	enable_1510_mode = d->dev_caps & ENABLE_1510_MODE;
332f31cc962SG, Manjunath Kondaiah 
33382809601STony Lindgren 	if (cpu_is_omap16xx())
33482809601STony Lindgren 		d->dev_caps = ENABLE_16XX_MODE;
33582809601STony Lindgren 
336f31cc962SG, Manjunath Kondaiah 	d->dev_caps		|= SRC_PORT;
337f31cc962SG, Manjunath Kondaiah 	d->dev_caps		|= DST_PORT;
338f31cc962SG, Manjunath Kondaiah 	d->dev_caps		|= SRC_INDEX;
339f31cc962SG, Manjunath Kondaiah 	d->dev_caps		|= DST_INDEX;
340f31cc962SG, Manjunath Kondaiah 	d->dev_caps		|= IS_BURST_ONLY4;
341f31cc962SG, Manjunath Kondaiah 	d->dev_caps		|= CLEAR_CSR_ON_READ;
342f31cc962SG, Manjunath Kondaiah 	d->dev_caps		|= IS_WORD_16;
343f31cc962SG, Manjunath Kondaiah 
34465727977SPeter Ujfalusi 	/* available logical channels */
34565727977SPeter Ujfalusi 	if (cpu_is_omap15xx()) {
34665727977SPeter Ujfalusi 		d->lch_count = 9;
34765727977SPeter Ujfalusi 	} else {
34865727977SPeter Ujfalusi 		if (d->dev_caps & ENABLE_1510_MODE)
34965727977SPeter Ujfalusi 			d->lch_count = 9;
350f31cc962SG, Manjunath Kondaiah 		else
35165727977SPeter Ujfalusi 			d->lch_count = 16;
352f31cc962SG, Manjunath Kondaiah 	}
353f31cc962SG, Manjunath Kondaiah 
35434a378fcSRussell King 	p = dma_plat_info;
35534a378fcSRussell King 	p.dma_attr = d;
35634a378fcSRussell King 	p.errata = configure_dma_errata();
357f31cc962SG, Manjunath Kondaiah 
358c4e35783SPeter Ujfalusi 	p.slave_map = omap1xxx_sdma_map;
359c4e35783SPeter Ujfalusi 	p.slavecnt = ARRAY_SIZE(omap1xxx_sdma_map);
360c4e35783SPeter Ujfalusi 
36134a378fcSRussell King 	ret = platform_device_add_data(pdev, &p, sizeof(p));
3626568f7c4SG, Manjunath Kondaiah 	if (ret) {
3636568f7c4SG, Manjunath Kondaiah 		dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n",
3646568f7c4SG, Manjunath Kondaiah 			__func__, pdev->name, pdev->id);
3659834f813SRussell King 		goto exit_release_d;
3666568f7c4SG, Manjunath Kondaiah 	}
3676568f7c4SG, Manjunath Kondaiah 
3686568f7c4SG, Manjunath Kondaiah 	ret = platform_device_add(pdev);
3696568f7c4SG, Manjunath Kondaiah 	if (ret) {
3706568f7c4SG, Manjunath Kondaiah 		dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n",
3716568f7c4SG, Manjunath Kondaiah 			__func__, pdev->name, pdev->id);
3729834f813SRussell King 		goto exit_release_d;
3736568f7c4SG, Manjunath Kondaiah 	}
3746568f7c4SG, Manjunath Kondaiah 
375be1f9481STony Lindgren 	dma_pdev = platform_device_register_full(&omap_dma_dev_info);
376be1f9481STony Lindgren 	if (IS_ERR(dma_pdev)) {
377be1f9481STony Lindgren 		ret = PTR_ERR(dma_pdev);
378be1f9481STony Lindgren 		goto exit_release_pdev;
379be1f9481STony Lindgren 	}
380be1f9481STony Lindgren 
3816568f7c4SG, Manjunath Kondaiah 	return ret;
3826568f7c4SG, Manjunath Kondaiah 
383be1f9481STony Lindgren exit_release_pdev:
384be1f9481STony Lindgren 	platform_device_del(pdev);
385f31cc962SG, Manjunath Kondaiah exit_release_d:
386f31cc962SG, Manjunath Kondaiah 	kfree(d);
387348c3422SWei Yongjun exit_iounmap:
388348c3422SWei Yongjun 	iounmap(dma_base);
38977f7059aSJulia Lawall exit_device_put:
39077f7059aSJulia Lawall 	platform_device_put(pdev);
3916568f7c4SG, Manjunath Kondaiah 
3926568f7c4SG, Manjunath Kondaiah 	return ret;
3936568f7c4SG, Manjunath Kondaiah }
3946568f7c4SG, Manjunath Kondaiah arch_initcall(omap1_system_dma_init);
395