diff options
author | Valentin Longchamp <valentin.longchamp@epfl.ch> | 2009-11-03 12:09:51 -0500 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-11-14 04:29:15 -0500 |
commit | 04ea3c801905a4562cc89af78eba40dec0f960a9 (patch) | |
tree | 51dd16f2bae5032e60720bb7b7d92f499e1a6651 /arch/arm/mach-mx3/mx31moboard.c | |
parent | 4dd7129345be71cb20da99a75ded01ea50615f66 (diff) |
mx31moboard: camera support
We have two mt9t031 cameras that have a muxed bus on the robot.
Only one is currently initialized because of limitations in
soc_camera that should be removed later.
Signed-off-by: Valentin Longchamp <valentin.longchamp@epfl.ch>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-mx3/mx31moboard.c')
-rw-r--r-- | arch/arm/mach-mx3/mx31moboard.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/arch/arm/mach-mx3/mx31moboard.c b/arch/arm/mach-mx3/mx31moboard.c index 2f95dcd805cc..b167f131f7c0 100644 --- a/arch/arm/mach-mx3/mx31moboard.c +++ b/arch/arm/mach-mx3/mx31moboard.c | |||
@@ -17,6 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/dma-mapping.h> | ||
20 | #include <linux/fsl_devices.h> | 21 | #include <linux/fsl_devices.h> |
21 | #include <linux/gpio.h> | 22 | #include <linux/gpio.h> |
22 | #include <linux/init.h> | 23 | #include <linux/init.h> |
@@ -403,6 +404,39 @@ static struct platform_device *devices[] __initdata = { | |||
403 | &mx31moboard_leds_device, | 404 | &mx31moboard_leds_device, |
404 | }; | 405 | }; |
405 | 406 | ||
407 | static struct mx3_camera_pdata camera_pdata = { | ||
408 | .dma_dev = &mx3_ipu.dev, | ||
409 | .flags = MX3_CAMERA_DATAWIDTH_8 | MX3_CAMERA_DATAWIDTH_10, | ||
410 | .mclk_10khz = 4800, | ||
411 | }; | ||
412 | |||
413 | #define CAMERA_BUF_SIZE (4*1024*1024) | ||
414 | |||
415 | static int __init mx31moboard_cam_alloc_dma(const size_t buf_size) | ||
416 | { | ||
417 | dma_addr_t dma_handle; | ||
418 | void *buf; | ||
419 | int dma; | ||
420 | |||
421 | if (buf_size < 2 * 1024 * 1024) | ||
422 | return -EINVAL; | ||
423 | |||
424 | buf = dma_alloc_coherent(NULL, buf_size, &dma_handle, GFP_KERNEL); | ||
425 | if (!buf) { | ||
426 | pr_err("%s: cannot allocate camera buffer-memory\n", __func__); | ||
427 | return -ENOMEM; | ||
428 | } | ||
429 | |||
430 | memset(buf, 0, buf_size); | ||
431 | |||
432 | dma = dma_declare_coherent_memory(&mx3_camera.dev, | ||
433 | dma_handle, dma_handle, buf_size, | ||
434 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); | ||
435 | |||
436 | /* The way we call dma_declare_coherent_memory only a malloc can fail */ | ||
437 | return dma & DMA_MEMORY_MAP ? 0 : -ENOMEM; | ||
438 | } | ||
439 | |||
406 | static int mx31moboard_baseboard; | 440 | static int mx31moboard_baseboard; |
407 | core_param(mx31moboard_baseboard, mx31moboard_baseboard, int, 0444); | 441 | core_param(mx31moboard_baseboard, mx31moboard_baseboard, int, 0444); |
408 | 442 | ||
@@ -436,6 +470,8 @@ static void __init mxc_board_init(void) | |||
436 | mxc_register_device(&mxcsdhc_device0, &sdhc1_pdata); | 470 | mxc_register_device(&mxcsdhc_device0, &sdhc1_pdata); |
437 | 471 | ||
438 | mxc_register_device(&mx3_ipu, &mx3_ipu_data); | 472 | mxc_register_device(&mx3_ipu, &mx3_ipu_data); |
473 | if (!mx31moboard_cam_alloc_dma(CAMERA_BUF_SIZE)) | ||
474 | mxc_register_device(&mx3_camera, &camera_pdata); | ||
439 | 475 | ||
440 | usb_xcvr_reset(); | 476 | usb_xcvr_reset(); |
441 | 477 | ||