aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2011-03-03 05:39:42 -0500
committerSascha Hauer <s.hauer@pengutronix.de>2011-05-19 07:11:18 -0400
commitdca7c0b4293a06d1ed9387e729a4882896abccc2 (patch)
tree7d4f683051c0c31379d477ae0e6253bb29cf5fcb /arch/arm
parent83422671c3e93b8ef77805fbad74173a1636d5f1 (diff)
ARM: mx3/pcm037: properly allocate memory for mx3-camera
There is no need to memzero the buffer because dma_alloc_coherent zeros the memory for us. This fixes: BUG: Your driver calls ioremap() on system memory. This leads <4>to architecturally unpredictable behaviour on ARMv6+, and ioremap() <4>will fail in the next kernel release. Please fix your driver. Tested-by: Michael Grzeschik <mgr@pengutronix.de> LAKML-Reference: 1299271882-2130-3-git-send-email-u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-mx3/mach-pcm037.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/arch/arm/mach-mx3/mach-pcm037.c b/arch/arm/mach-mx3/mach-pcm037.c
index f07d3bded674..497b39b0f0e4 100644
--- a/arch/arm/mach-mx3/mach-pcm037.c
+++ b/arch/arm/mach-mx3/mach-pcm037.c
@@ -31,6 +31,7 @@
31#include <linux/usb/otg.h> 31#include <linux/usb/otg.h>
32#include <linux/usb/ulpi.h> 32#include <linux/usb/ulpi.h>
33#include <linux/gfp.h> 33#include <linux/gfp.h>
34#include <linux/memblock.h>
34 35
35#include <media/soc_camera.h> 36#include <media/soc_camera.h>
36 37
@@ -410,25 +411,16 @@ struct mx3_camera_pdata camera_pdata = {
410 .mclk_10khz = 2000, 411 .mclk_10khz = 2000,
411}; 412};
412 413
413static int __init pcm037_camera_alloc_dma(const size_t buf_size) 414static phys_addr_t mx3_camera_base __initdata;
415#define MX3_CAMERA_BUF_SIZE SZ_4M
416
417static int __init pcm037_camera_alloc_dma(void)
414{ 418{
415 dma_addr_t dma_handle;
416 void *buf;
417 int dma; 419 int dma;
418 420
419 if (buf_size < 2 * 1024 * 1024)
420 return -EINVAL;
421
422 buf = dma_alloc_coherent(NULL, buf_size, &dma_handle, GFP_KERNEL);
423 if (!buf) {
424 pr_err("%s: cannot allocate camera buffer-memory\n", __func__);
425 return -ENOMEM;
426 }
427
428 memset(buf, 0, buf_size);
429
430 dma = dma_declare_coherent_memory(&mx3_camera.dev, 421 dma = dma_declare_coherent_memory(&mx3_camera.dev,
431 dma_handle, dma_handle, buf_size, 422 mx3_camera_base, mx3_camera_base,
423 MX3_CAMERA_BUF_SIZE,
432 DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); 424 DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
433 425
434 /* The way we call dma_declare_coherent_memory only a malloc can fail */ 426 /* The way we call dma_declare_coherent_memory only a malloc can fail */
@@ -649,7 +641,7 @@ static void __init pcm037_init(void)
649 else 641 else
650 iclink_mt9t031.power = NULL; 642 iclink_mt9t031.power = NULL;
651 643
652 if (!pcm037_camera_alloc_dma(4 * 1024 * 1024)) 644 if (!pcm037_camera_alloc_dma())
653 mxc_register_device(&mx3_camera, &camera_pdata); 645 mxc_register_device(&mx3_camera, &camera_pdata);
654 646
655 platform_device_register(&pcm970_sja1000); 647 platform_device_register(&pcm970_sja1000);
@@ -680,9 +672,19 @@ struct sys_timer pcm037_timer = {
680 .init = pcm037_timer_init, 672 .init = pcm037_timer_init,
681}; 673};
682 674
675static void __init pcm037_reserve(void)
676{
677 /* reserve 4 MiB for mx3-camera */
678 mx3_camera_base = memblock_alloc(MX3_CAMERA_BUF_SIZE,
679 MX3_CAMERA_BUF_SIZE);
680 memblock_free(mx3_camera_base, MX3_CAMERA_BUF_SIZE);
681 memblock_remove(mx3_camera_base, MX3_CAMERA_BUF_SIZE);
682}
683
683MACHINE_START(PCM037, "Phytec Phycore pcm037") 684MACHINE_START(PCM037, "Phytec Phycore pcm037")
684 /* Maintainer: Pengutronix */ 685 /* Maintainer: Pengutronix */
685 .boot_params = MX3x_PHYS_OFFSET + 0x100, 686 .boot_params = MX3x_PHYS_OFFSET + 0x100,
687 .reserve = pcm037_reserve,
686 .map_io = mx31_map_io, 688 .map_io = mx31_map_io,
687 .init_early = imx31_init_early, 689 .init_early = imx31_init_early,
688 .init_irq = mx31_init_irq, 690 .init_irq = mx31_init_irq,