diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2011-03-03 15:32:02 -0500 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-05-19 07:11:20 -0400 |
commit | afa77ef30ead4865ce2c0c1c55054d45521ce1c7 (patch) | |
tree | 87a455605b7d0ae9685e71ae7fd48a1a0d87d379 /arch/arm/mach-mx3/mach-pcm037.c | |
parent | 031e912741746e4350204bb0436590ca0e993a7d (diff) |
ARM: mx3: dynamically allocate "ipu-core" devices
... together with the related devices "mx3_camera" and "mx3_sdc_fb".
"mx3_camera" doesn't fit the scheme of the other devices that just are
allocated and registered in a single function because it needs additional
care to get some dmaable memory. So currently imx31_alloc_mx3_camera
duplicates most of imx_add_platform_device_dmamask, but I'm not sure it's
worth to split the latter to be able to reuse more code.
This gets rid of mach-mx3/devices.[ch] and so several files need to be
adapted not to #include devices.h anymore.
LAKML-Reference: 1299271882-2130-5-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/mach-mx3/mach-pcm037.c')
-rw-r--r-- | arch/arm/mach-mx3/mach-pcm037.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/arch/arm/mach-mx3/mach-pcm037.c b/arch/arm/mach-mx3/mach-pcm037.c index 497b39b0f0e4..89c213b81295 100644 --- a/arch/arm/mach-mx3/mach-pcm037.c +++ b/arch/arm/mach-mx3/mach-pcm037.c | |||
@@ -42,13 +42,9 @@ | |||
42 | #include <mach/common.h> | 42 | #include <mach/common.h> |
43 | #include <mach/hardware.h> | 43 | #include <mach/hardware.h> |
44 | #include <mach/iomux-mx3.h> | 44 | #include <mach/iomux-mx3.h> |
45 | #include <mach/ipu.h> | ||
46 | #include <mach/mx3_camera.h> | ||
47 | #include <mach/mx3fb.h> | ||
48 | #include <mach/ulpi.h> | 45 | #include <mach/ulpi.h> |
49 | 46 | ||
50 | #include "devices-imx31.h" | 47 | #include "devices-imx31.h" |
51 | #include "devices.h" | ||
52 | #include "pcm037.h" | 48 | #include "pcm037.h" |
53 | 49 | ||
54 | static enum pcm037_board_variant pcm037_instance = PCM037_PCM970; | 50 | static enum pcm037_board_variant pcm037_instance = PCM037_PCM970; |
@@ -405,8 +401,7 @@ static const struct imxmmc_platform_data sdhc_pdata __initconst = { | |||
405 | .exit = pcm970_sdhc1_exit, | 401 | .exit = pcm970_sdhc1_exit, |
406 | }; | 402 | }; |
407 | 403 | ||
408 | struct mx3_camera_pdata camera_pdata = { | 404 | struct mx3_camera_pdata camera_pdata __initdata = { |
409 | .dma_dev = &mx3_ipu.dev, | ||
410 | .flags = MX3_CAMERA_DATAWIDTH_8 | MX3_CAMERA_DATAWIDTH_10, | 405 | .flags = MX3_CAMERA_DATAWIDTH_8 | MX3_CAMERA_DATAWIDTH_10, |
411 | .mclk_10khz = 2000, | 406 | .mclk_10khz = 2000, |
412 | }; | 407 | }; |
@@ -414,17 +409,27 @@ struct mx3_camera_pdata camera_pdata = { | |||
414 | static phys_addr_t mx3_camera_base __initdata; | 409 | static phys_addr_t mx3_camera_base __initdata; |
415 | #define MX3_CAMERA_BUF_SIZE SZ_4M | 410 | #define MX3_CAMERA_BUF_SIZE SZ_4M |
416 | 411 | ||
417 | static int __init pcm037_camera_alloc_dma(void) | 412 | static int __init pcm037_init_camera(void) |
418 | { | 413 | { |
419 | int dma; | 414 | int dma, ret = -ENOMEM; |
415 | struct platform_device *pdev = imx31_alloc_mx3_camera(&camera_pdata); | ||
420 | 416 | ||
421 | dma = dma_declare_coherent_memory(&mx3_camera.dev, | 417 | if (IS_ERR(pdev)) |
418 | return PTR_ERR(pdev); | ||
419 | |||
420 | dma = dma_declare_coherent_memory(&pdev->dev, | ||
422 | mx3_camera_base, mx3_camera_base, | 421 | mx3_camera_base, mx3_camera_base, |
423 | MX3_CAMERA_BUF_SIZE, | 422 | MX3_CAMERA_BUF_SIZE, |
424 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); | 423 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); |
424 | if (!(dma & DMA_MEMORY_MAP)) | ||
425 | goto err; | ||
426 | |||
427 | ret = platform_device_add(pdev); | ||
428 | if (ret) | ||
429 | err: | ||
430 | platform_device_put(pdev); | ||
425 | 431 | ||
426 | /* The way we call dma_declare_coherent_memory only a malloc can fail */ | 432 | return ret; |
427 | return dma & DMA_MEMORY_MAP ? 0 : -ENOMEM; | ||
428 | } | 433 | } |
429 | 434 | ||
430 | static struct platform_device *devices[] __initdata = { | 435 | static struct platform_device *devices[] __initdata = { |
@@ -434,7 +439,7 @@ static struct platform_device *devices[] __initdata = { | |||
434 | &pcm037_mt9v022, | 439 | &pcm037_mt9v022, |
435 | }; | 440 | }; |
436 | 441 | ||
437 | static struct ipu_platform_data mx3_ipu_data = { | 442 | static const struct ipu_platform_data mx3_ipu_data __initconst = { |
438 | .irq_base = MXC_IPU_IRQ_START, | 443 | .irq_base = MXC_IPU_IRQ_START, |
439 | }; | 444 | }; |
440 | 445 | ||
@@ -492,7 +497,6 @@ static const struct fb_videomode fb_modedb[] = { | |||
492 | }; | 497 | }; |
493 | 498 | ||
494 | static struct mx3fb_platform_data mx3fb_pdata = { | 499 | static struct mx3fb_platform_data mx3fb_pdata = { |
495 | .dma_dev = &mx3_ipu.dev, | ||
496 | .name = "Sharp-LQ035Q7DH06-QVGA", | 500 | .name = "Sharp-LQ035Q7DH06-QVGA", |
497 | .mode = fb_modedb, | 501 | .mode = fb_modedb, |
498 | .num_modes = ARRAY_SIZE(fb_modedb), | 502 | .num_modes = ARRAY_SIZE(fb_modedb), |
@@ -630,8 +634,8 @@ static void __init pcm037_init(void) | |||
630 | 634 | ||
631 | imx31_add_mxc_nand(&pcm037_nand_board_info); | 635 | imx31_add_mxc_nand(&pcm037_nand_board_info); |
632 | imx31_add_mxc_mmc(0, &sdhc_pdata); | 636 | imx31_add_mxc_mmc(0, &sdhc_pdata); |
633 | mxc_register_device(&mx3_ipu, &mx3_ipu_data); | 637 | imx31_add_ipu_core(&mx3_ipu_data); |
634 | mxc_register_device(&mx3_fb, &mx3fb_pdata); | 638 | imx31_add_mx3_sdc_fb(&mx3fb_pdata); |
635 | 639 | ||
636 | /* CSI */ | 640 | /* CSI */ |
637 | /* Camera power: default - off */ | 641 | /* Camera power: default - off */ |
@@ -641,8 +645,7 @@ static void __init pcm037_init(void) | |||
641 | else | 645 | else |
642 | iclink_mt9t031.power = NULL; | 646 | iclink_mt9t031.power = NULL; |
643 | 647 | ||
644 | if (!pcm037_camera_alloc_dma()) | 648 | pcm037_init_camera(); |
645 | mxc_register_device(&mx3_camera, &camera_pdata); | ||
646 | 649 | ||
647 | platform_device_register(&pcm970_sja1000); | 650 | platform_device_register(&pcm970_sja1000); |
648 | 651 | ||