diff options
| author | Baruch Siach <baruch@tkos.co.il> | 2010-07-04 00:55:10 -0400 |
|---|---|---|
| committer | Sascha Hauer <s.hauer@pengutronix.de> | 2010-07-28 03:28:36 -0400 |
| commit | 2066930de6296ef7470de11eaa9b8bc9129721e8 (patch) | |
| tree | 109fb2f88a5dce7b95f58771845ed0feccaa4b92 | |
| parent | 14cb0deb66fcfca8fdbef75da8c84b5405a8c767 (diff) | |
mx2_camera: Add soc_camera support for i.MX25/i.MX27
This is the soc_camera support developed by Sascha Hauer for the i.MX27. Alan
Carvalho de Assis modified the original driver to get it working on more recent
kernels. I modified it further to add support for i.MX25. This driver has been
tested on i.MX25 and i.MX27 based platforms.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| -rw-r--r-- | arch/arm/plat-mxc/include/mach/memory.h | 4 | ||||
| -rw-r--r-- | arch/arm/plat-mxc/include/mach/mx2_cam.h | 46 | ||||
| -rw-r--r-- | drivers/media/video/Kconfig | 13 | ||||
| -rw-r--r-- | drivers/media/video/Makefile | 1 | ||||
| -rw-r--r-- | drivers/media/video/mx2_camera.c | 1513 |
5 files changed, 1575 insertions, 2 deletions
diff --git a/arch/arm/plat-mxc/include/mach/memory.h b/arch/arm/plat-mxc/include/mach/memory.h index c4b40c35a6a1..564ec9dbc93d 100644 --- a/arch/arm/plat-mxc/include/mach/memory.h +++ b/arch/arm/plat-mxc/include/mach/memory.h | |||
| @@ -44,12 +44,12 @@ | |||
| 44 | */ | 44 | */ |
| 45 | #define CONSISTENT_DMA_SIZE SZ_8M | 45 | #define CONSISTENT_DMA_SIZE SZ_8M |
| 46 | 46 | ||
| 47 | #elif defined(CONFIG_MX1_VIDEO) | 47 | #elif defined(CONFIG_MX1_VIDEO) || defined(CONFIG_VIDEO_MX2_HOSTSUPPORT) |
| 48 | /* | 48 | /* |
| 49 | * Increase size of DMA-consistent memory region. | 49 | * Increase size of DMA-consistent memory region. |
| 50 | * This is required for i.MX camera driver to capture at least four VGA frames. | 50 | * This is required for i.MX camera driver to capture at least four VGA frames. |
| 51 | */ | 51 | */ |
| 52 | #define CONSISTENT_DMA_SIZE SZ_4M | 52 | #define CONSISTENT_DMA_SIZE SZ_4M |
| 53 | #endif /* CONFIG_MX1_VIDEO */ | 53 | #endif /* CONFIG_MX1_VIDEO || CONFIG_VIDEO_MX2_HOSTSUPPORT */ |
| 54 | 54 | ||
| 55 | #endif /* __ASM_ARCH_MXC_MEMORY_H__ */ | 55 | #endif /* __ASM_ARCH_MXC_MEMORY_H__ */ |
diff --git a/arch/arm/plat-mxc/include/mach/mx2_cam.h b/arch/arm/plat-mxc/include/mach/mx2_cam.h new file mode 100644 index 000000000000..3c080a32dbf5 --- /dev/null +++ b/arch/arm/plat-mxc/include/mach/mx2_cam.h | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | /* | ||
| 2 | * mx2-cam.h - i.MX27/i.MX25 camera driver header file | ||
| 3 | * | ||
| 4 | * Copyright (C) 2003, Intel Corporation | ||
| 5 | * Copyright (C) 2008, Sascha Hauer <s.hauer@pengutronix.de> | ||
| 6 | * Copyright (C) 2010, Baruch Siach <baruch@tkos.co.il> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2 of the License, or | ||
| 11 | * (at your option) any later version. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License | ||
| 19 | * along with this program; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 21 | */ | ||
| 22 | |||
| 23 | #ifndef __MACH_MX2_CAM_H_ | ||
| 24 | #define __MACH_MX2_CAM_H_ | ||
| 25 | |||
| 26 | #define MX2_CAMERA_SWAP16 (1 << 0) | ||
| 27 | #define MX2_CAMERA_EXT_VSYNC (1 << 1) | ||
| 28 | #define MX2_CAMERA_CCIR (1 << 2) | ||
| 29 | #define MX2_CAMERA_CCIR_INTERLACE (1 << 3) | ||
| 30 | #define MX2_CAMERA_HSYNC_HIGH (1 << 4) | ||
| 31 | #define MX2_CAMERA_GATED_CLOCK (1 << 5) | ||
| 32 | #define MX2_CAMERA_INV_DATA (1 << 6) | ||
| 33 | #define MX2_CAMERA_PCLK_SAMPLE_RISING (1 << 7) | ||
| 34 | #define MX2_CAMERA_PACK_DIR_MSB (1 << 8) | ||
| 35 | |||
| 36 | /** | ||
| 37 | * struct mx2_camera_platform_data - optional platform data for mx2_camera | ||
| 38 | * @flags: any combination of MX2_CAMERA_* | ||
| 39 | * @clk: clock rate of the csi block / 2 | ||
| 40 | */ | ||
| 41 | struct mx2_camera_platform_data { | ||
| 42 | unsigned long flags; | ||
| 43 | unsigned long clk; | ||
| 44 | }; | ||
| 45 | |||
| 46 | #endif /* __MACH_MX2_CAM_H_ */ | ||
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index ad9e6f9c22e9..cdbbbe491d1b 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
| @@ -969,6 +969,19 @@ config VIDEO_OMAP2 | |||
| 969 | ---help--- | 969 | ---help--- |
| 970 | This is a v4l2 driver for the TI OMAP2 camera capture interface | 970 | This is a v4l2 driver for the TI OMAP2 camera capture interface |
| 971 | 971 | ||
| 972 | config VIDEO_MX2_HOSTSUPPORT | ||
| 973 | bool | ||
| 974 | |||
| 975 | config VIDEO_MX2 | ||
| 976 | tristate "i.MX27/i.MX25 Camera Sensor Interface driver" | ||
| 977 | depends on VIDEO_DEV && SOC_CAMERA && (MACH_MX27 || ARCH_MX25) | ||
| 978 | select VIDEOBUF_DMA_CONTIG | ||
| 979 | select VIDEO_MX2_HOSTSUPPORT | ||
| 980 | ---help--- | ||
| 981 | This is a v4l2 driver for the i.MX27 and the i.MX25 Camera Sensor | ||
| 982 | Interface | ||
| 983 | |||
| 984 | |||
| 972 | # | 985 | # |
| 973 | # USB Multimedia device configuration | 986 | # USB Multimedia device configuration |
| 974 | # | 987 | # |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index cc93859d3164..b08bd2b65cd0 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
| @@ -162,6 +162,7 @@ obj-$(CONFIG_SOC_CAMERA) += soc_camera.o soc_mediabus.o | |||
| 162 | obj-$(CONFIG_SOC_CAMERA_PLATFORM) += soc_camera_platform.o | 162 | obj-$(CONFIG_SOC_CAMERA_PLATFORM) += soc_camera_platform.o |
| 163 | # soc-camera host drivers have to be linked after camera drivers | 163 | # soc-camera host drivers have to be linked after camera drivers |
| 164 | obj-$(CONFIG_VIDEO_MX1) += mx1_camera.o | 164 | obj-$(CONFIG_VIDEO_MX1) += mx1_camera.o |
| 165 | obj-$(CONFIG_VIDEO_MX2) += mx2_camera.o | ||
| 165 | obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o | 166 | obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o |
| 166 | obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o | 167 | obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o |
| 167 | obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o | 168 | obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o |
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c new file mode 100644 index 000000000000..98c93faa0c8d --- /dev/null +++ b/drivers/media/video/mx2_camera.c | |||
| @@ -0,0 +1,1513 @@ | |||
| 1 | /* | ||
| 2 | * V4L2 Driver for i.MX27/i.MX25 camera host | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008, Sascha Hauer, Pengutronix | ||
| 5 | * Copyright (C) 2010, Baruch Siach, Orex Computed Radiography | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * (at your option) any later version. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/init.h> | ||
| 14 | #include <linux/module.h> | ||
| 15 | #include <linux/io.h> | ||
| 16 | #include <linux/delay.h> | ||
| 17 | #include <linux/slab.h> | ||
| 18 | #include <linux/dma-mapping.h> | ||
| 19 | #include <linux/errno.h> | ||
| 20 | #include <linux/fs.h> | ||
| 21 | #include <linux/interrupt.h> | ||
| 22 | #include <linux/kernel.h> | ||
| 23 | #include <linux/mm.h> | ||
| 24 | #include <linux/moduleparam.h> | ||
| 25 | #include <linux/time.h> | ||
| 26 | #include <linux/version.h> | ||
| 27 | #include <linux/device.h> | ||
| 28 | #include <linux/platform_device.h> | ||
| 29 | #include <linux/mutex.h> | ||
| 30 | #include <linux/clk.h> | ||
| 31 | |||
| 32 | #include <media/v4l2-common.h> | ||
| 33 | #include <media/v4l2-dev.h> | ||
| 34 | #include <media/videobuf-dma-contig.h> | ||
| 35 | #include <media/soc_camera.h> | ||
| 36 | #include <media/soc_mediabus.h> | ||
| 37 | |||
| 38 | #include <linux/videodev2.h> | ||
| 39 | |||
| 40 | #include <mach/mx2_cam.h> | ||
| 41 | #ifdef CONFIG_MACH_MX27 | ||
| 42 | #include <mach/dma-mx1-mx2.h> | ||
| 43 | #endif | ||
| 44 | #include <mach/hardware.h> | ||
| 45 | |||
| 46 | #include <asm/dma.h> | ||
| 47 | |||
| 48 | #define MX2_CAM_DRV_NAME "mx2-camera" | ||
| 49 | #define MX2_CAM_VERSION_CODE KERNEL_VERSION(0, 0, 5) | ||
| 50 | #define MX2_CAM_DRIVER_DESCRIPTION "i.MX2x_Camera" | ||
| 51 | |||
| 52 | /* reset values */ | ||
| 53 | #define CSICR1_RESET_VAL 0x40000800 | ||
| 54 | #define CSICR2_RESET_VAL 0x0 | ||
| 55 | #define CSICR3_RESET_VAL 0x0 | ||
| 56 | |||
| 57 | /* csi control reg 1 */ | ||
| 58 | #define CSICR1_SWAP16_EN (1 << 31) | ||
| 59 | #define CSICR1_EXT_VSYNC (1 << 30) | ||
| 60 | #define CSICR1_EOF_INTEN (1 << 29) | ||
| 61 | #define CSICR1_PRP_IF_EN (1 << 28) | ||
| 62 | #define CSICR1_CCIR_MODE (1 << 27) | ||
| 63 | #define CSICR1_COF_INTEN (1 << 26) | ||
| 64 | #define CSICR1_SF_OR_INTEN (1 << 25) | ||
| 65 | #define CSICR1_RF_OR_INTEN (1 << 24) | ||
| 66 | #define CSICR1_STATFF_LEVEL (3 << 22) | ||
| 67 | #define CSICR1_STATFF_INTEN (1 << 21) | ||
| 68 | #define CSICR1_RXFF_LEVEL(l) (((l) & 3) << 19) /* MX27 */ | ||
| 69 | #define CSICR1_FB2_DMA_INTEN (1 << 20) /* MX25 */ | ||
| 70 | #define CSICR1_FB1_DMA_INTEN (1 << 19) /* MX25 */ | ||
| 71 | #define CSICR1_RXFF_INTEN (1 << 18) | ||
| 72 | #define CSICR1_SOF_POL (1 << 17) | ||
| 73 | #define CSICR1_SOF_INTEN (1 << 16) | ||
| 74 | #define CSICR1_MCLKDIV(d) (((d) & 0xF) << 12) | ||
| 75 | #define CSICR1_HSYNC_POL (1 << 11) | ||
| 76 | #define CSICR1_CCIR_EN (1 &l | ||
