aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/plat-omap/dma.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index 0eb676d7e807..034686d66894 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -2347,40 +2347,46 @@ EXPORT_SYMBOL(omap_stop_lcd_dma);
2347 2347
2348static int __init omap_init_dma(void) 2348static int __init omap_init_dma(void)
2349{ 2349{
2350 unsigned long base;
2350 int ch, r; 2351 int ch, r;
2351 2352
2352 if (cpu_class_is_omap1()) { 2353 if (cpu_class_is_omap1()) {
2353 omap_dma_base = OMAP1_IO_ADDRESS(OMAP1_DMA_BASE); 2354 base = OMAP1_DMA_BASE;
2354 dma_lch_count = OMAP1_LOGICAL_DMA_CH_COUNT; 2355 dma_lch_count = OMAP1_LOGICAL_DMA_CH_COUNT;
2355 } else if (cpu_is_omap24xx()) { 2356 } else if (cpu_is_omap24xx()) {
2356 omap_dma_base = OMAP2_IO_ADDRESS(OMAP24XX_DMA4_BASE); 2357 base = OMAP24XX_DMA4_BASE;
2357 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT; 2358 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
2358 } else if (cpu_is_omap34xx()) { 2359 } else if (cpu_is_omap34xx()) {
2359 omap_dma_base = OMAP2_IO_ADDRESS(OMAP34XX_DMA4_BASE); 2360 base = OMAP34XX_DMA4_BASE;
2360 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT; 2361 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
2361 } else if (cpu_is_omap44xx()) { 2362 } else if (cpu_is_omap44xx()) {
2362 omap_dma_base = OMAP2_IO_ADDRESS(OMAP44XX_DMA4_BASE); 2363 base = OMAP44XX_DMA4_BASE;
2363 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT; 2364 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
2364 } else { 2365 } else {
2365 pr_err("DMA init failed for unsupported omap\n"); 2366 pr_err("DMA init failed for unsupported omap\n");
2366 return -ENODEV; 2367 return -ENODEV;
2367 } 2368 }
2368 2369
2370 omap_dma_base = ioremap(base, SZ_4K);
2371 BUG_ON(!omap_dma_base);
2372
2369 if (cpu_class_is_omap2() && omap_dma_reserve_channels 2373 if (cpu_class_is_omap2() && omap_dma_reserve_channels
2370 && (omap_dma_reserve_channels <= dma_lch_count)) 2374 && (omap_dma_reserve_channels <= dma_lch_count))
2371 dma_lch_count = omap_dma_reserve_channels; 2375 dma_lch_count = omap_dma_reserve_channels;
2372 2376
2373 dma_chan = kzalloc(sizeof(struct omap_dma_lch) * dma_lch_count, 2377 dma_chan = kzalloc(sizeof(struct omap_dma_lch) * dma_lch_count,
2374 GFP_KERNEL); 2378 GFP_KERNEL);
2375 if (!dma_chan) 2379 if (!dma_chan) {
2376 return -ENOMEM; 2380 r = -ENOMEM;
2381 goto out_unmap;
2382 }
2377 2383
2378 if (cpu_class_is_omap2()) { 2384 if (cpu_class_is_omap2()) {
2379 dma_linked_lch = kzalloc(sizeof(struct dma_link_info) * 2385 dma_linked_lch = kzalloc(sizeof(struct dma_link_info) *
2380 dma_lch_count, GFP_KERNEL); 2386 dma_lch_count, GFP_KERNEL);
2381 if (!dma_linked_lch) { 2387 if (!dma_linked_lch) {
2382 kfree(dma_chan); 2388 r = -ENOMEM;
2383 return -ENOMEM; 2389 goto out_free;
2384 } 2390 }
2385 } 2391 }
2386 2392
@@ -2454,7 +2460,7 @@ static int __init omap_init_dma(void)
2454 for (i = 0; i < ch; i++) 2460 for (i = 0; i < ch; i++)
2455 free_irq(omap1_dma_irq[i], 2461 free_irq(omap1_dma_irq[i],
2456 (void *) (i + 1)); 2462 (void *) (i + 1));
2457 return r; 2463 goto out_free;
2458 } 2464 }
2459 } 2465 }
2460 } 2466 }
@@ -2496,11 +2502,19 @@ static int __init omap_init_dma(void)
2496 "(error %d)\n", r); 2502 "(error %d)\n", r);
2497 for (i = 0; i < dma_chan_count; i++) 2503 for (i = 0; i < dma_chan_count; i++)
2498 free_irq(omap1_dma_irq[i], (void *) (i + 1)); 2504 free_irq(omap1_dma_irq[i], (void *) (i + 1));
2499 return r; 2505 goto out_free;
2500 } 2506 }
2501 } 2507 }
2502 2508
2503 return 0; 2509 return 0;
2510
2511out_free:
2512 kfree(dma_chan);
2513
2514out_unmap:
2515 iounmap(omap_dma_base);
2516
2517 return r;
2504} 2518}
2505 2519
2506arch_initcall(omap_init_dma); 2520arch_initcall(omap_init_dma);