aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-mx3/mach-mx31_3ds.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2011-03-03 15:32:02 -0500
committerSascha Hauer <s.hauer@pengutronix.de>2011-05-19 07:11:20 -0400
commitafa77ef30ead4865ce2c0c1c55054d45521ce1c7 (patch)
tree87a455605b7d0ae9685e71ae7fd48a1a0d87d379 /arch/arm/mach-mx3/mach-mx31_3ds.c
parent031e912741746e4350204bb0436590ca0e993a7d (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-mx31_3ds.c')
-rw-r--r--arch/arm/mach-mx3/mach-mx31_3ds.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/arch/arm/mach-mx3/mach-mx31_3ds.c b/arch/arm/mach-mx3/mach-mx31_3ds.c
index 477b2d274396..9b982449cb52 100644
--- a/arch/arm/mach-mx3/mach-mx31_3ds.c
+++ b/arch/arm/mach-mx3/mach-mx31_3ds.c
@@ -39,12 +39,8 @@
39#include <mach/iomux-mx3.h> 39#include <mach/iomux-mx3.h>
40#include <mach/3ds_debugboard.h> 40#include <mach/3ds_debugboard.h>
41#include <mach/ulpi.h> 41#include <mach/ulpi.h>
42#include <mach/ipu.h>
43#include <mach/mx3fb.h>
44#include <mach/mx3_camera.h>
45 42
46#include "devices-imx31.h" 43#include "devices-imx31.h"
47#include "devices.h"
48 44
49/* CPLD IRQ line for external uart, external ethernet etc */ 45/* CPLD IRQ line for external uart, external ethernet etc */
50#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1) 46#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1)
@@ -177,22 +173,37 @@ static struct gpio mx31_3ds_camera_gpios[] = {
177 { MX31_3DS_GPIO_CAMERA_RST, GPIOF_OUT_INIT_HIGH, "camera-reset" }, 173 { MX31_3DS_GPIO_CAMERA_RST, GPIOF_OUT_INIT_HIGH, "camera-reset" },
178}; 174};
179 175
180static int __init mx31_3ds_camera_alloc_dma(void) 176static const struct mx3_camera_pdata mx31_3ds_camera_pdata __initconst = {
177 .flags = MX3_CAMERA_DATAWIDTH_10,
178 .mclk_10khz = 2600,
179};
180
181static int __init mx31_3ds_init_camera(void)
181{ 182{
182 int dma; 183 int dma, ret = -ENOMEM;
184 struct platform_device *pdev =
185 imx31_alloc_mx3_camera(&mx31_3ds_camera_pdata);
186
187 if (IS_ERR(pdev))
188 return PTR_ERR(pdev);
183 189
184 if (!mx3_camera_base) 190 if (!mx3_camera_base)
185 return -ENOMEM; 191 goto err;
186 192
187 dma = dma_declare_coherent_memory(&mx3_camera.dev, 193 dma = dma_declare_coherent_memory(&pdev->dev,
188 mx3_camera_base, mx3_camera_base, 194 mx3_camera_base, mx3_camera_base,
189 MX31_3DS_CAMERA_BUF_SIZE, 195 MX31_3DS_CAMERA_BUF_SIZE,
190 DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); 196 DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
191 197
192 if (!(dma & DMA_MEMORY_MAP)) 198 if (!(dma & DMA_MEMORY_MAP))
193 return -ENOMEM; 199 goto err;
194 200
195 return 0; 201 ret = platform_device_add(pdev);
202 if (ret)
203err:
204 platform_device_put(pdev);
205
206 return ret;
196} 207}
197 208
198static int mx31_3ds_camera_power(struct device *dev, int on) 209static int mx31_3ds_camera_power(struct device *dev, int on)
@@ -240,12 +251,6 @@ static struct platform_device mx31_3ds_ov2640 = {
240 }, 251 },
241}; 252};
242 253
243struct mx3_camera_pdata mx31_3ds_camera_pdata = {
244 .dma_dev = &mx3_ipu.dev,
245 .flags = MX3_CAMERA_DATAWIDTH_10,
246 .mclk_10khz = 2600,
247};
248
249/* 254/*
250 * FB support 255 * FB support
251 */ 256 */
@@ -272,8 +277,7 @@ static struct ipu_platform_data mx3_ipu_data = {
272 .irq_base = MXC_IPU_IRQ_START, 277 .irq_base = MXC_IPU_IRQ_START,
273}; 278};
274 279
275static struct mx3fb_platform_data mx3fb_pdata = { 280static struct mx3fb_platform_data mx3fb_pdata __initdata = {
276 .dma_dev = &mx3_ipu.dev,
277 .name = "Epson-VGA", 281 .name = "Epson-VGA",
278 .mode = fb_modedb, 282 .mode = fb_modedb,
279 .num_modes = ARRAY_SIZE(fb_modedb), 283 .num_modes = ARRAY_SIZE(fb_modedb),
@@ -722,8 +726,8 @@ static void __init mx31_3ds_init(void)
722 imx31_add_mxc_mmc(0, &sdhc1_pdata); 726 imx31_add_mxc_mmc(0, &sdhc1_pdata);
723 727
724 imx31_add_spi_imx0(&spi0_pdata); 728 imx31_add_spi_imx0(&spi0_pdata);
725 mxc_register_device(&mx3_ipu, &mx3_ipu_data); 729 imx31_add_ipu_core(&mx3_ipu_data);
726 mxc_register_device(&mx3_fb, &mx3fb_pdata); 730 imx31_add_mx3_sdc_fb(&mx3fb_pdata);
727 731
728 /* CSI */ 732 /* CSI */
729 /* Camera power: default - off */ 733 /* Camera power: default - off */
@@ -734,10 +738,7 @@ static void __init mx31_3ds_init(void)
734 iclink_ov2640.power = NULL; 738 iclink_ov2640.power = NULL;
735 } 739 }
736 740
737 if (!mx31_3ds_camera_alloc_dma()) 741 mx31_3ds_init_camera();
738 mxc_register_device(&mx3_camera, &mx31_3ds_camera_pdata);
739 else
740 pr_err("Failed to allocate dma memory for camera");
741} 742}
742 743
743static void __init mx31_3ds_timer_init(void) 744static void __init mx31_3ds_timer_init(void)