xref: /linux/arch/arm/mach-omap2/dma.c (revision f31cc9622d75c1c6f041d786698daa425c0425c2)
159de3cf1SG, Manjunath Kondaiah /*
259de3cf1SG, Manjunath Kondaiah  * OMAP2+ DMA driver
359de3cf1SG, Manjunath Kondaiah  *
459de3cf1SG, Manjunath Kondaiah  * Copyright (C) 2003 - 2008 Nokia Corporation
559de3cf1SG, Manjunath Kondaiah  * Author: Juha Yrjölä <juha.yrjola@nokia.com>
659de3cf1SG, Manjunath Kondaiah  * DMA channel linking for 1610 by Samuel Ortiz <samuel.ortiz@nokia.com>
759de3cf1SG, Manjunath Kondaiah  * Graphics DMA and LCD DMA graphics tranformations
859de3cf1SG, Manjunath Kondaiah  * by Imre Deak <imre.deak@nokia.com>
959de3cf1SG, Manjunath Kondaiah  * OMAP2/3 support Copyright (C) 2004-2007 Texas Instruments, Inc.
1059de3cf1SG, Manjunath Kondaiah  * Some functions based on earlier dma-omap.c Copyright (C) 2001 RidgeRun, Inc.
1159de3cf1SG, Manjunath Kondaiah  *
1259de3cf1SG, Manjunath Kondaiah  * Copyright (C) 2009 Texas Instruments
1359de3cf1SG, Manjunath Kondaiah  * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
1459de3cf1SG, Manjunath Kondaiah  *
1559de3cf1SG, Manjunath Kondaiah  * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
1659de3cf1SG, Manjunath Kondaiah  * Converted DMA library into platform driver
1759de3cf1SG, Manjunath Kondaiah  *	- G, Manjunath Kondaiah <manjugk@ti.com>
1859de3cf1SG, Manjunath Kondaiah  *
1959de3cf1SG, Manjunath Kondaiah  * This program is free software; you can redistribute it and/or modify
2059de3cf1SG, Manjunath Kondaiah  * it under the terms of the GNU General Public License version 2 as
2159de3cf1SG, Manjunath Kondaiah  * published by the Free Software Foundation.
2259de3cf1SG, Manjunath Kondaiah  */
2359de3cf1SG, Manjunath Kondaiah 
2459de3cf1SG, Manjunath Kondaiah #include <linux/err.h>
2559de3cf1SG, Manjunath Kondaiah #include <linux/io.h>
2659de3cf1SG, Manjunath Kondaiah #include <linux/slab.h>
2759de3cf1SG, Manjunath Kondaiah #include <linux/module.h>
2859de3cf1SG, Manjunath Kondaiah #include <linux/init.h>
2959de3cf1SG, Manjunath Kondaiah #include <linux/device.h>
3059de3cf1SG, Manjunath Kondaiah 
3159de3cf1SG, Manjunath Kondaiah #include <plat/omap_hwmod.h>
3259de3cf1SG, Manjunath Kondaiah #include <plat/omap_device.h>
3359de3cf1SG, Manjunath Kondaiah #include <plat/dma.h>
3459de3cf1SG, Manjunath Kondaiah 
35*f31cc962SG, Manjunath Kondaiah #define OMAP2_DMA_STRIDE	0x60
36*f31cc962SG, Manjunath Kondaiah 
37*f31cc962SG, Manjunath Kondaiah static u32 errata;
38*f31cc962SG, Manjunath Kondaiah static u8 dma_stride;
39*f31cc962SG, Manjunath Kondaiah 
40*f31cc962SG, Manjunath Kondaiah static struct omap_dma_dev_attr *d;
41*f31cc962SG, Manjunath Kondaiah 
42*f31cc962SG, Manjunath Kondaiah static enum omap_reg_offsets dma_common_ch_start, dma_common_ch_end;
43*f31cc962SG, Manjunath Kondaiah 
44*f31cc962SG, Manjunath Kondaiah static u16 reg_map[] = {
45*f31cc962SG, Manjunath Kondaiah 	[REVISION]		= 0x00,
46*f31cc962SG, Manjunath Kondaiah 	[GCR]			= 0x78,
47*f31cc962SG, Manjunath Kondaiah 	[IRQSTATUS_L0]		= 0x08,
48*f31cc962SG, Manjunath Kondaiah 	[IRQSTATUS_L1]		= 0x0c,
49*f31cc962SG, Manjunath Kondaiah 	[IRQSTATUS_L2]		= 0x10,
50*f31cc962SG, Manjunath Kondaiah 	[IRQSTATUS_L3]		= 0x14,
51*f31cc962SG, Manjunath Kondaiah 	[IRQENABLE_L0]		= 0x18,
52*f31cc962SG, Manjunath Kondaiah 	[IRQENABLE_L1]		= 0x1c,
53*f31cc962SG, Manjunath Kondaiah 	[IRQENABLE_L2]		= 0x20,
54*f31cc962SG, Manjunath Kondaiah 	[IRQENABLE_L3]		= 0x24,
55*f31cc962SG, Manjunath Kondaiah 	[SYSSTATUS]		= 0x28,
56*f31cc962SG, Manjunath Kondaiah 	[OCP_SYSCONFIG]		= 0x2c,
57*f31cc962SG, Manjunath Kondaiah 	[CAPS_0]		= 0x64,
58*f31cc962SG, Manjunath Kondaiah 	[CAPS_2]		= 0x6c,
59*f31cc962SG, Manjunath Kondaiah 	[CAPS_3]		= 0x70,
60*f31cc962SG, Manjunath Kondaiah 	[CAPS_4]		= 0x74,
61*f31cc962SG, Manjunath Kondaiah 
62*f31cc962SG, Manjunath Kondaiah 	/* Common register offsets */
63*f31cc962SG, Manjunath Kondaiah 	[CCR]			= 0x80,
64*f31cc962SG, Manjunath Kondaiah 	[CLNK_CTRL]		= 0x84,
65*f31cc962SG, Manjunath Kondaiah 	[CICR]			= 0x88,
66*f31cc962SG, Manjunath Kondaiah 	[CSR]			= 0x8c,
67*f31cc962SG, Manjunath Kondaiah 	[CSDP]			= 0x90,
68*f31cc962SG, Manjunath Kondaiah 	[CEN]			= 0x94,
69*f31cc962SG, Manjunath Kondaiah 	[CFN]			= 0x98,
70*f31cc962SG, Manjunath Kondaiah 	[CSEI]			= 0xa4,
71*f31cc962SG, Manjunath Kondaiah 	[CSFI]			= 0xa8,
72*f31cc962SG, Manjunath Kondaiah 	[CDEI]			= 0xac,
73*f31cc962SG, Manjunath Kondaiah 	[CDFI]			= 0xb0,
74*f31cc962SG, Manjunath Kondaiah 	[CSAC]			= 0xb4,
75*f31cc962SG, Manjunath Kondaiah 	[CDAC]			= 0xb8,
76*f31cc962SG, Manjunath Kondaiah 
77*f31cc962SG, Manjunath Kondaiah 	/* Channel specific register offsets */
78*f31cc962SG, Manjunath Kondaiah 	[CSSA]			= 0x9c,
79*f31cc962SG, Manjunath Kondaiah 	[CDSA]			= 0xa0,
80*f31cc962SG, Manjunath Kondaiah 	[CCEN]			= 0xbc,
81*f31cc962SG, Manjunath Kondaiah 	[CCFN]			= 0xc0,
82*f31cc962SG, Manjunath Kondaiah 	[COLOR]			= 0xc4,
83*f31cc962SG, Manjunath Kondaiah 
84*f31cc962SG, Manjunath Kondaiah 	/* OMAP4 specific registers */
85*f31cc962SG, Manjunath Kondaiah 	[CDP]			= 0xd0,
86*f31cc962SG, Manjunath Kondaiah 	[CNDP]			= 0xd4,
87*f31cc962SG, Manjunath Kondaiah 	[CCDN]			= 0xd8,
88*f31cc962SG, Manjunath Kondaiah };
89*f31cc962SG, Manjunath Kondaiah 
9059de3cf1SG, Manjunath Kondaiah static struct omap_device_pm_latency omap2_dma_latency[] = {
9159de3cf1SG, Manjunath Kondaiah 	{
9259de3cf1SG, Manjunath Kondaiah 		.deactivate_func = omap_device_idle_hwmods,
9359de3cf1SG, Manjunath Kondaiah 		.activate_func	 = omap_device_enable_hwmods,
9459de3cf1SG, Manjunath Kondaiah 		.flags		 = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
9559de3cf1SG, Manjunath Kondaiah 	},
9659de3cf1SG, Manjunath Kondaiah };
9759de3cf1SG, Manjunath Kondaiah 
98*f31cc962SG, Manjunath Kondaiah static void __iomem *dma_base;
99*f31cc962SG, Manjunath Kondaiah static inline void dma_write(u32 val, int reg, int lch)
100*f31cc962SG, Manjunath Kondaiah {
101*f31cc962SG, Manjunath Kondaiah 	u8  stride;
102*f31cc962SG, Manjunath Kondaiah 	u32 offset;
103*f31cc962SG, Manjunath Kondaiah 
104*f31cc962SG, Manjunath Kondaiah 	stride = (reg >= dma_common_ch_start) ? dma_stride : 0;
105*f31cc962SG, Manjunath Kondaiah 	offset = reg_map[reg] + (stride * lch);
106*f31cc962SG, Manjunath Kondaiah 	__raw_writel(val, dma_base + offset);
107*f31cc962SG, Manjunath Kondaiah }
108*f31cc962SG, Manjunath Kondaiah 
109*f31cc962SG, Manjunath Kondaiah static inline u32 dma_read(int reg, int lch)
110*f31cc962SG, Manjunath Kondaiah {
111*f31cc962SG, Manjunath Kondaiah 	u8 stride;
112*f31cc962SG, Manjunath Kondaiah 	u32 offset, val;
113*f31cc962SG, Manjunath Kondaiah 
114*f31cc962SG, Manjunath Kondaiah 	stride = (reg >= dma_common_ch_start) ? dma_stride : 0;
115*f31cc962SG, Manjunath Kondaiah 	offset = reg_map[reg] + (stride * lch);
116*f31cc962SG, Manjunath Kondaiah 	val = __raw_readl(dma_base + offset);
117*f31cc962SG, Manjunath Kondaiah 	return val;
118*f31cc962SG, Manjunath Kondaiah }
119*f31cc962SG, Manjunath Kondaiah 
120*f31cc962SG, Manjunath Kondaiah static inline void omap2_disable_irq_lch(int lch)
121*f31cc962SG, Manjunath Kondaiah {
122*f31cc962SG, Manjunath Kondaiah 	u32 val;
123*f31cc962SG, Manjunath Kondaiah 
124*f31cc962SG, Manjunath Kondaiah 	val = dma_read(IRQENABLE_L0, lch);
125*f31cc962SG, Manjunath Kondaiah 	val &= ~(1 << lch);
126*f31cc962SG, Manjunath Kondaiah 	dma_write(val, IRQENABLE_L0, lch);
127*f31cc962SG, Manjunath Kondaiah }
128*f31cc962SG, Manjunath Kondaiah 
129*f31cc962SG, Manjunath Kondaiah static void omap2_clear_dma(int lch)
130*f31cc962SG, Manjunath Kondaiah {
131*f31cc962SG, Manjunath Kondaiah 	int i = dma_common_ch_start;
132*f31cc962SG, Manjunath Kondaiah 
133*f31cc962SG, Manjunath Kondaiah 	for (; i <= dma_common_ch_end; i += 1)
134*f31cc962SG, Manjunath Kondaiah 		dma_write(0, i, lch);
135*f31cc962SG, Manjunath Kondaiah }
136*f31cc962SG, Manjunath Kondaiah 
137*f31cc962SG, Manjunath Kondaiah static void omap2_show_dma_caps(void)
138*f31cc962SG, Manjunath Kondaiah {
139*f31cc962SG, Manjunath Kondaiah 	u8 revision = dma_read(REVISION, 0) & 0xff;
140*f31cc962SG, Manjunath Kondaiah 	printk(KERN_INFO "OMAP DMA hardware revision %d.%d\n",
141*f31cc962SG, Manjunath Kondaiah 				revision >> 4, revision & 0xf);
142*f31cc962SG, Manjunath Kondaiah 	return;
143*f31cc962SG, Manjunath Kondaiah }
144*f31cc962SG, Manjunath Kondaiah 
145*f31cc962SG, Manjunath Kondaiah static u32 configure_dma_errata(void)
146*f31cc962SG, Manjunath Kondaiah {
147*f31cc962SG, Manjunath Kondaiah 
148*f31cc962SG, Manjunath Kondaiah 	/*
149*f31cc962SG, Manjunath Kondaiah 	 * Errata applicable for OMAP2430ES1.0 and all omap2420
150*f31cc962SG, Manjunath Kondaiah 	 *
151*f31cc962SG, Manjunath Kondaiah 	 * I.
152*f31cc962SG, Manjunath Kondaiah 	 * Erratum ID: Not Available
153*f31cc962SG, Manjunath Kondaiah 	 * Inter Frame DMA buffering issue DMA will wrongly
154*f31cc962SG, Manjunath Kondaiah 	 * buffer elements if packing and bursting is enabled. This might
155*f31cc962SG, Manjunath Kondaiah 	 * result in data gets stalled in FIFO at the end of the block.
156*f31cc962SG, Manjunath Kondaiah 	 * Workaround: DMA channels must have BUFFERING_DISABLED bit set to
157*f31cc962SG, Manjunath Kondaiah 	 * guarantee no data will stay in the DMA FIFO in case inter frame
158*f31cc962SG, Manjunath Kondaiah 	 * buffering occurs
159*f31cc962SG, Manjunath Kondaiah 	 *
160*f31cc962SG, Manjunath Kondaiah 	 * II.
161*f31cc962SG, Manjunath Kondaiah 	 * Erratum ID: Not Available
162*f31cc962SG, Manjunath Kondaiah 	 * DMA may hang when several channels are used in parallel
163*f31cc962SG, Manjunath Kondaiah 	 * In the following configuration, DMA channel hanging can occur:
164*f31cc962SG, Manjunath Kondaiah 	 * a. Channel i, hardware synchronized, is enabled
165*f31cc962SG, Manjunath Kondaiah 	 * b. Another channel (Channel x), software synchronized, is enabled.
166*f31cc962SG, Manjunath Kondaiah 	 * c. Channel i is disabled before end of transfer
167*f31cc962SG, Manjunath Kondaiah 	 * d. Channel i is reenabled.
168*f31cc962SG, Manjunath Kondaiah 	 * e. Steps 1 to 4 are repeated a certain number of times.
169*f31cc962SG, Manjunath Kondaiah 	 * f. A third channel (Channel y), software synchronized, is enabled.
170*f31cc962SG, Manjunath Kondaiah 	 * Channel x and Channel y may hang immediately after step 'f'.
171*f31cc962SG, Manjunath Kondaiah 	 * Workaround:
172*f31cc962SG, Manjunath Kondaiah 	 * For any channel used - make sure NextLCH_ID is set to the value j.
173*f31cc962SG, Manjunath Kondaiah 	 */
174*f31cc962SG, Manjunath Kondaiah 	if (cpu_is_omap2420() || (cpu_is_omap2430() &&
175*f31cc962SG, Manjunath Kondaiah 				(omap_type() == OMAP2430_REV_ES1_0))) {
176*f31cc962SG, Manjunath Kondaiah 
177*f31cc962SG, Manjunath Kondaiah 		SET_DMA_ERRATA(DMA_ERRATA_IFRAME_BUFFERING);
178*f31cc962SG, Manjunath Kondaiah 		SET_DMA_ERRATA(DMA_ERRATA_PARALLEL_CHANNELS);
179*f31cc962SG, Manjunath Kondaiah 	}
180*f31cc962SG, Manjunath Kondaiah 
181*f31cc962SG, Manjunath Kondaiah 	/*
182*f31cc962SG, Manjunath Kondaiah 	 * Erratum ID: i378: OMAP2+: sDMA Channel is not disabled
183*f31cc962SG, Manjunath Kondaiah 	 * after a transaction error.
184*f31cc962SG, Manjunath Kondaiah 	 * Workaround: SW should explicitely disable the channel.
185*f31cc962SG, Manjunath Kondaiah 	 */
186*f31cc962SG, Manjunath Kondaiah 	if (cpu_class_is_omap2())
187*f31cc962SG, Manjunath Kondaiah 		SET_DMA_ERRATA(DMA_ERRATA_i378);
188*f31cc962SG, Manjunath Kondaiah 
189*f31cc962SG, Manjunath Kondaiah 	/*
190*f31cc962SG, Manjunath Kondaiah 	 * Erratum ID: i541: sDMA FIFO draining does not finish
191*f31cc962SG, Manjunath Kondaiah 	 * If sDMA channel is disabled on the fly, sDMA enters standby even
192*f31cc962SG, Manjunath Kondaiah 	 * through FIFO Drain is still in progress
193*f31cc962SG, Manjunath Kondaiah 	 * Workaround: Put sDMA in NoStandby more before a logical channel is
194*f31cc962SG, Manjunath Kondaiah 	 * disabled, then put it back to SmartStandby right after the channel
195*f31cc962SG, Manjunath Kondaiah 	 * finishes FIFO draining.
196*f31cc962SG, Manjunath Kondaiah 	 */
197*f31cc962SG, Manjunath Kondaiah 	if (cpu_is_omap34xx())
198*f31cc962SG, Manjunath Kondaiah 		SET_DMA_ERRATA(DMA_ERRATA_i541);
199*f31cc962SG, Manjunath Kondaiah 
200*f31cc962SG, Manjunath Kondaiah 	/*
201*f31cc962SG, Manjunath Kondaiah 	 * Erratum ID: i88 : Special programming model needed to disable DMA
202*f31cc962SG, Manjunath Kondaiah 	 * before end of block.
203*f31cc962SG, Manjunath Kondaiah 	 * Workaround: software must ensure that the DMA is configured in No
204*f31cc962SG, Manjunath Kondaiah 	 * Standby mode(DMAx_OCP_SYSCONFIG.MIDLEMODE = "01")
205*f31cc962SG, Manjunath Kondaiah 	 */
206*f31cc962SG, Manjunath Kondaiah 	if (omap_type() == OMAP3430_REV_ES1_0)
207*f31cc962SG, Manjunath Kondaiah 		SET_DMA_ERRATA(DMA_ERRATA_i88);
208*f31cc962SG, Manjunath Kondaiah 
209*f31cc962SG, Manjunath Kondaiah 	/*
210*f31cc962SG, Manjunath Kondaiah 	 * Erratum 3.2/3.3: sometimes 0 is returned if CSAC/CDAC is
211*f31cc962SG, Manjunath Kondaiah 	 * read before the DMA controller finished disabling the channel.
212*f31cc962SG, Manjunath Kondaiah 	 */
213*f31cc962SG, Manjunath Kondaiah 	SET_DMA_ERRATA(DMA_ERRATA_3_3);
214*f31cc962SG, Manjunath Kondaiah 
215*f31cc962SG, Manjunath Kondaiah 	/*
216*f31cc962SG, Manjunath Kondaiah 	 * Erratum ID: Not Available
217*f31cc962SG, Manjunath Kondaiah 	 * A bug in ROM code leaves IRQ status for channels 0 and 1 uncleared
218*f31cc962SG, Manjunath Kondaiah 	 * after secure sram context save and restore.
219*f31cc962SG, Manjunath Kondaiah 	 * Work around: Hence we need to manually clear those IRQs to avoid
220*f31cc962SG, Manjunath Kondaiah 	 * spurious interrupts. This affects only secure devices.
221*f31cc962SG, Manjunath Kondaiah 	 */
222*f31cc962SG, Manjunath Kondaiah 	if (cpu_is_omap34xx() && (omap_type() != OMAP2_DEVICE_TYPE_GP))
223*f31cc962SG, Manjunath Kondaiah 		SET_DMA_ERRATA(DMA_ROMCODE_BUG);
224*f31cc962SG, Manjunath Kondaiah 
225*f31cc962SG, Manjunath Kondaiah 	return errata;
226*f31cc962SG, Manjunath Kondaiah }
227*f31cc962SG, Manjunath Kondaiah 
22859de3cf1SG, Manjunath Kondaiah /* One time initializations */
22959de3cf1SG, Manjunath Kondaiah static int __init omap2_system_dma_init_dev(struct omap_hwmod *oh, void *unused)
23059de3cf1SG, Manjunath Kondaiah {
23159de3cf1SG, Manjunath Kondaiah 	struct omap_device			*od;
23259de3cf1SG, Manjunath Kondaiah 	struct omap_system_dma_plat_info	*p;
233*f31cc962SG, Manjunath Kondaiah 	struct resource				*mem;
23459de3cf1SG, Manjunath Kondaiah 	char					*name = "omap_dma_system";
23559de3cf1SG, Manjunath Kondaiah 
236*f31cc962SG, Manjunath Kondaiah 	dma_stride		= OMAP2_DMA_STRIDE;
237*f31cc962SG, Manjunath Kondaiah 	dma_common_ch_start	= CSDP;
238*f31cc962SG, Manjunath Kondaiah 	if (cpu_is_omap3630() || cpu_is_omap4430())
239*f31cc962SG, Manjunath Kondaiah 		dma_common_ch_end = CCDN;
240*f31cc962SG, Manjunath Kondaiah 	else
241*f31cc962SG, Manjunath Kondaiah 		dma_common_ch_end = CCFN;
242*f31cc962SG, Manjunath Kondaiah 
24359de3cf1SG, Manjunath Kondaiah 	p = kzalloc(sizeof(struct omap_system_dma_plat_info), GFP_KERNEL);
24459de3cf1SG, Manjunath Kondaiah 	if (!p) {
24559de3cf1SG, Manjunath Kondaiah 		pr_err("%s: Unable to allocate pdata for %s:%s\n",
24659de3cf1SG, Manjunath Kondaiah 			__func__, name, oh->name);
24759de3cf1SG, Manjunath Kondaiah 		return -ENOMEM;
24859de3cf1SG, Manjunath Kondaiah 	}
24959de3cf1SG, Manjunath Kondaiah 
250*f31cc962SG, Manjunath Kondaiah 	p->dma_attr		= (struct omap_dma_dev_attr *)oh->dev_attr;
251*f31cc962SG, Manjunath Kondaiah 	p->disable_irq_lch	= omap2_disable_irq_lch;
252*f31cc962SG, Manjunath Kondaiah 	p->show_dma_caps	= omap2_show_dma_caps;
253*f31cc962SG, Manjunath Kondaiah 	p->clear_dma		= omap2_clear_dma;
254*f31cc962SG, Manjunath Kondaiah 	p->dma_write		= dma_write;
255*f31cc962SG, Manjunath Kondaiah 	p->dma_read		= dma_read;
256*f31cc962SG, Manjunath Kondaiah 
257*f31cc962SG, Manjunath Kondaiah 	p->clear_lch_regs	= NULL;
258*f31cc962SG, Manjunath Kondaiah 
259*f31cc962SG, Manjunath Kondaiah 	p->errata		= configure_dma_errata();
260*f31cc962SG, Manjunath Kondaiah 
26159de3cf1SG, Manjunath Kondaiah 	od = omap_device_build(name, 0, oh, p, sizeof(*p),
26259de3cf1SG, Manjunath Kondaiah 			omap2_dma_latency, ARRAY_SIZE(omap2_dma_latency), 0);
26359de3cf1SG, Manjunath Kondaiah 	kfree(p);
26459de3cf1SG, Manjunath Kondaiah 	if (IS_ERR(od)) {
26559de3cf1SG, Manjunath Kondaiah 		pr_err("%s: Cant build omap_device for %s:%s.\n",
26659de3cf1SG, Manjunath Kondaiah 			__func__, name, oh->name);
26759de3cf1SG, Manjunath Kondaiah 		return IS_ERR(od);
26859de3cf1SG, Manjunath Kondaiah 	}
26959de3cf1SG, Manjunath Kondaiah 
270*f31cc962SG, Manjunath Kondaiah 	mem = platform_get_resource(&od->pdev, IORESOURCE_MEM, 0);
271*f31cc962SG, Manjunath Kondaiah 	if (!mem) {
272*f31cc962SG, Manjunath Kondaiah 		dev_err(&od->pdev.dev, "%s: no mem resource\n", __func__);
273*f31cc962SG, Manjunath Kondaiah 		return -EINVAL;
274*f31cc962SG, Manjunath Kondaiah 	}
275*f31cc962SG, Manjunath Kondaiah 	dma_base = ioremap(mem->start, resource_size(mem));
276*f31cc962SG, Manjunath Kondaiah 	if (!dma_base) {
277*f31cc962SG, Manjunath Kondaiah 		dev_err(&od->pdev.dev, "%s: ioremap fail\n", __func__);
278*f31cc962SG, Manjunath Kondaiah 		return -ENOMEM;
279*f31cc962SG, Manjunath Kondaiah 	}
280*f31cc962SG, Manjunath Kondaiah 
281*f31cc962SG, Manjunath Kondaiah 	d = oh->dev_attr;
282*f31cc962SG, Manjunath Kondaiah 	d->chan = kzalloc(sizeof(struct omap_dma_lch) *
283*f31cc962SG, Manjunath Kondaiah 					(d->lch_count), GFP_KERNEL);
284*f31cc962SG, Manjunath Kondaiah 
285*f31cc962SG, Manjunath Kondaiah 	if (!d->chan) {
286*f31cc962SG, Manjunath Kondaiah 		dev_err(&od->pdev.dev, "%s: kzalloc fail\n", __func__);
287*f31cc962SG, Manjunath Kondaiah 		return -ENOMEM;
288*f31cc962SG, Manjunath Kondaiah 	}
28959de3cf1SG, Manjunath Kondaiah 	return 0;
29059de3cf1SG, Manjunath Kondaiah }
29159de3cf1SG, Manjunath Kondaiah 
29259de3cf1SG, Manjunath Kondaiah static int __init omap2_system_dma_init(void)
29359de3cf1SG, Manjunath Kondaiah {
29459de3cf1SG, Manjunath Kondaiah 	return omap_hwmod_for_each_by_class("dma",
29559de3cf1SG, Manjunath Kondaiah 			omap2_system_dma_init_dev, NULL);
29659de3cf1SG, Manjunath Kondaiah }
29759de3cf1SG, Manjunath Kondaiah arch_initcall(omap2_system_dma_init);
298