From afa77ef30ead4865ce2c0c1c55054d45521ce1c7 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Thu, 3 Mar 2011 21:32:02 +0100 Subject: ARM: mx3: dynamically allocate "ipu-core" devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... 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 Signed-off-by: Sascha Hauer --- arch/arm/mach-mx3/mach-mx31moboard.c | 39 +++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'arch/arm/mach-mx3/mach-mx31moboard.c') diff --git a/arch/arm/mach-mx3/mach-mx31moboard.c b/arch/arm/mach-mx3/mach-mx31moboard.c index 6c13061b6ac2..eaaea2dbd4fd 100644 --- a/arch/arm/mach-mx3/mach-mx31moboard.c +++ b/arch/arm/mach-mx3/mach-mx31moboard.c @@ -40,12 +40,9 @@ #include #include #include -#include -#include #include #include "devices-imx31.h" -#include "devices.h" static unsigned int moboard_pins[] = { /* UART0 */ @@ -194,8 +191,8 @@ static struct regulator_init_data sdhc_vreg_data = { static struct regulator_consumer_supply cam_consumers[] = { { - .dev = &mx3_camera.dev, - .supply = "cam_vcc", + .dev_name = "mx3_camera.0", + .supply = "cam_vcc", }, }; @@ -458,7 +455,7 @@ static struct platform_device mx31moboard_leds_device = { }, }; -static struct ipu_platform_data mx3_ipu_data = { +static const struct ipu_platform_data mx3_ipu_data __initconst = { .irq_base = MXC_IPU_IRQ_START, }; @@ -467,8 +464,7 @@ static struct platform_device *devices[] __initdata = { &mx31moboard_leds_device, }; -static struct mx3_camera_pdata camera_pdata = { - .dma_dev = &mx3_ipu.dev, +static struct mx3_camera_pdata camera_pdata __initdata = { .flags = MX3_CAMERA_DATAWIDTH_8 | MX3_CAMERA_DATAWIDTH_10, .mclk_10khz = 4800, }; @@ -476,18 +472,31 @@ static struct mx3_camera_pdata camera_pdata = { static phys_addr_t mx3_camera_base __initdata; #define MX3_CAMERA_BUF_SIZE SZ_4M -static int __init mx31moboard_cam_alloc_dma(void) +static int __init mx31moboard_init_cam(void) { - int dma; + int dma, ret = -ENOMEM; + struct platform_device *pdev; + + imx31_add_ipu_core(&mx3_ipu_data); + pdev = imx31_alloc_mx3_camera(&camera_pdata); + if (IS_ERR(pdev)) + return PTR_ERR(pdev); - dma = dma_declare_coherent_memory(&mx3_camera.dev, + dma = dma_declare_coherent_memory(&pdev->dev, mx3_camera_base, mx3_camera_base, MX3_CAMERA_BUF_SIZE, DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); + if (!(dma & DMA_MEMORY_MAP)) + goto err; + + ret = platform_device_add(pdev); + if (ret) +err: + platform_device_put(pdev); + + return ret; - /* The way we call dma_declare_coherent_memory only a malloc can fail */ - return dma & DMA_MEMORY_MAP ? 0 : -ENOMEM; } static int mx31moboard_baseboard; @@ -519,9 +528,7 @@ static void __init mx31moboard_init(void) imx31_add_mxc_mmc(0, &sdhc1_pdata); - mxc_register_device(&mx3_ipu, &mx3_ipu_data); - if (!mx31moboard_cam_alloc_dma()) - mxc_register_device(&mx3_camera, &camera_pdata); + mx31moboard_init_cam(); usb_xcvr_reset(); -- cgit v1.2.3