b058200a81e768cbce5fbbca2047ca0b100d7822
[glsdk/meta-ti-glsdk.git] / recipes-bsp / linux / linux-omap-psp-2.6.32 / cam / 0047-omap3beagle-camera-Bring-back-mt9t111-support.patch
1 From 046dac666301c0df22679424169675045c70defd Mon Sep 17 00:00:00 2001
2 From: Sergio Aguirre <saaguirre@ti.com>
3 Date: Mon, 12 Jul 2010 16:42:41 -0500
4 Subject: [PATCH 47/75] omap3beagle: camera: Bring back mt9t111 support
6 Restore MT9T111 sensor support.
8 Signed-off-by: Sergio Aguirre <saaguirre@ti.com>
9 ---
10 arch/arm/mach-omap2/board-omap3beagle-camera.c | 175 +++++++++++++++++++++++-
11 arch/arm/mach-omap2/board-omap3beagle.c | 12 ++
12 2 files changed, 184 insertions(+), 3 deletions(-)
14 diff --git a/arch/arm/mach-omap2/board-omap3beagle-camera.c b/arch/arm/mach-omap2/board-omap3beagle-camera.c
15 index c91529d..2e49158 100644
16 --- a/arch/arm/mach-omap2/board-omap3beagle-camera.c
17 +++ b/arch/arm/mach-omap2/board-omap3beagle-camera.c
18 @@ -37,7 +37,6 @@
19 #include <plat/control.h>
21 #include <media/v4l2-int-device.h>
22 -#include <media/mt9v113.h>
24 /* Include V4L2 ISP-Camera driver related header file */
25 #include <../drivers/media/video/omap34xxcam.h>
26 @@ -47,13 +46,16 @@
28 #define CAM_USE_XCLKA 0
30 -#define ISP_MT9V113_MCLK 216000000
31 -
32 #define LEOPARD_RESET_GPIO 98
34 static struct regulator *cam_1v8_reg;
35 static struct regulator *cam_2v8_reg;
37 +#if defined(CONFIG_VIDEO_MT9V113) || defined(CONFIG_VIDEO_MT9V113_MODULE)
38 +#include <media/mt9v113.h>
39 +
40 +#define ISP_MT9V113_MCLK 216000000
41 +
42 /* Arbitrary memory handling limit */
43 #define MT9V113_MAX_FRAME_SIZE PAGE_ALIGN(640 * 480 * 4)
45 @@ -199,6 +201,173 @@ struct mt9v113_platform_data mt9v113_pdata = {
46 .ifparm = mt9v113_ifparm,
47 };
49 +#endif /* #ifdef CONFIG_VIDEO_MT9V113 */
50 +
51 +#if defined(CONFIG_VIDEO_MT9T111) || defined(CONFIG_VIDEO_MT9T111_MODULE)
52 +#include <media/mt9t111.h>
53 +
54 +#define ISP_MT9T111_MCLK 216000000
55 +
56 +/* Arbitrary memory handling limit */
57 +#define MT9T111_BIGGEST_FRAME_BYTE_SIZE PAGE_ALIGN((2048 * 2) * 1536 * 4)
58 +
59 +static struct isp_interface_config mt9t111_if_config = {
60 + .ccdc_par_ser = ISP_PARLL,
61 + .dataline_shift = 0x2,
62 + .hsvs_syncdetect = ISPCTRL_SYNC_DETECT_VSRISE,
63 + .strobe = 0x0,
64 + .prestrobe = 0x0,
65 + .shutter = 0x0,
66 + .cam_mclk = ISP_MT9T111_MCLK,
67 + .wenlog = ISPCCDC_CFG_WENLOG_AND,
68 + .wait_hs_vs = 2,
69 + .u.par.par_bridge = 0x3,
70 + .u.par.par_clk_pol = 0x0,
71 +};
72 +
73 +static struct v4l2_ifparm mt9t111_ifparm_s = {
74 + .if_type = V4L2_IF_TYPE_RAW,
75 + .u = {
76 + .raw = {
77 + .frame_start_on_rising_vs = 1,
78 + .bt_sync_correct = 0,
79 + .swap = 0,
80 + .latch_clk_inv = 0,
81 + .nobt_hs_inv = 0, /* active high */
82 + .nobt_vs_inv = 0, /* active high */
83 + .clock_min = MT9T111_CLK_MIN,
84 + .clock_max = MT9T111_CLK_MAX,
85 + },
86 + },
87 +};
88 +
89 +/**
90 + * @brief mt9t111_ifparm - Returns the mt9t111 interface parameters
91 + *
92 + * @param p - pointer to v4l2_ifparm structure
93 + *
94 + * @return result of operation - 0 is success
95 + */
96 +static int mt9t111_ifparm(struct v4l2_ifparm *p)
97 +{
98 + if (p == NULL)
99 + return -EINVAL;
100 +
101 + *p = mt9t111_ifparm_s;
102 + return 0;
103 +}
104 +
105 +#if defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
106 +static struct omap34xxcam_hw_config mt9t111_hwc = {
107 + .dev_index = 0,
108 + .dev_minor = 0,
109 + .dev_type = OMAP34XXCAM_SLAVE_SENSOR,
110 + .u.sensor.sensor_isp = 0,
111 + .u.sensor.capture_mem = MT9T111_BIGGEST_FRAME_BYTE_SIZE,
112 + .u.sensor.ival_default = { 1, 10 },
113 +};
114 +#endif
115 +
116 +/**
117 + * @brief mt9t111_set_prv_data - Returns mt9t111 omap34xx driver private data
118 + *
119 + * @param priv - pointer to omap34xxcam_hw_config structure
120 + *
121 + * @return result of operation - 0 is success
122 + */
123 +static int mt9t111_set_prv_data(void *priv)
124 +{
125 +#if defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
126 + struct omap34xxcam_hw_config *hwc = priv;
127 +
128 + if (priv == NULL)
129 + return -EINVAL;
130 +
131 + *hwc = mt9t111_hwc;
132 + return 0;
133 +#else
134 + return -EINVAL;
135 +#endif
136 +}
137 +
138 +/**
139 + * @brief mt9t111_power_set - Power-on or power-off TVP5146 device
140 + *
141 + * @param power - enum, Power on/off, resume/standby
142 + *
143 + * @return result of operation - 0 is success
144 + */
145 +static int mt9t111_power_set(struct v4l2_int_device *s, enum v4l2_power power)
146 +{
147 + struct omap34xxcam_videodev *vdev = s->u.slave->master->priv;
148 +
149 + switch (power) {
150 + case V4L2_POWER_OFF:
151 + case V4L2_POWER_STANDBY:
152 + isp_set_xclk(vdev->cam->isp, 0, CAM_USE_XCLKA);
153 +
154 + if (regulator_is_enabled(cam_1v8_reg))
155 + regulator_disable(cam_1v8_reg);
156 + if (regulator_is_enabled(cam_2v8_reg))
157 + regulator_disable(cam_2v8_reg);
158 + break;
159 +
160 + case V4L2_POWER_ON:
161 +#if defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
162 + isp_configure_interface(vdev->cam->isp, &mt9t111_if_config);
163 +#endif
164 +
165 + /* Set RESET_BAR to 0 */
166 + gpio_set_value(LEOPARD_RESET_GPIO, 0);
167 +
168 + /* turn on VDD */
169 + regulator_enable(cam_1v8_reg);
170 +
171 + mdelay(1);
172 +
173 + /* turn on VDD_IO */
174 + regulator_enable(cam_2v8_reg);
175 +
176 + mdelay(50);
177 +
178 + /* Enable EXTCLK */
179 + isp_set_xclk(vdev->cam->isp, MT9T111_CLK_MIN, CAM_USE_XCLKA);
180 +
181 + /*
182 + * Wait at least 70 CLK cycles (w/EXTCLK = 6MHz, or CLK_MIN):
183 + * ((1000000 * 70) / 6000000) = aprox 12 us.
184 + */
185 +
186 + udelay(12);
187 +
188 + /* Set RESET_BAR to 1 */
189 + gpio_set_value(LEOPARD_RESET_GPIO, 1);
190 +
191 + /*
192 + * Wait at least 100 CLK cycles (w/EXTCLK = 6MHz, or CLK_MIN):
193 + * ((1000000 * 100) / 6000000) = aprox 17 us.
194 + */
195 +
196 + udelay(17);
197 +
198 + break;
199 +
200 + default:
201 + return -ENODEV;
202 + break;
203 + }
204 + return 0;
205 +}
206 +
207 +struct mt9t111_platform_data mt9t111_pdata = {
208 + .master = "omap34xxcam",
209 + .power_set = mt9t111_power_set,
210 + .priv_data_set = mt9t111_set_prv_data,
211 + .ifparm = mt9t111_ifparm,
212 +};
213 +
214 +#endif /* #ifdef CONFIG_VIDEO_MT9T111 */
215 +
216 static int beagle_cam_probe(struct platform_device *pdev)
217 {
218 cam_1v8_reg = regulator_get(&pdev->dev, "cam_1v8");
219 diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
220 index a1535ca..239bd44 100644
221 --- a/arch/arm/mach-omap2/board-omap3beagle.c
222 +++ b/arch/arm/mach-omap2/board-omap3beagle.c
223 @@ -77,6 +77,12 @@ static struct omap_opp * _omap37x_l3_rate_table = NULL;
224 extern struct mt9v113_platform_data mt9v113_pdata;
225 #endif
227 +#if defined(CONFIG_VIDEO_MT9T111) || defined(CONFIG_VIDEO_MT9T111_MODULE)
228 +#include <media/v4l2-int-device.h>
229 +#include <media/mt9t111.h>
230 +extern struct mt9t111_platform_data mt9t111_pdata;
231 +#endif
232 +
233 #define GPMC_CS0_BASE 0x60
234 #define GPMC_CS_SIZE 0x30
236 @@ -596,6 +602,12 @@ static struct i2c_board_info __initdata beagle_i2c2_boardinfo[] = {
237 .platform_data = &mt9v113_pdata,
238 },
239 #endif
240 +#if defined(CONFIG_VIDEO_MT9T111) || defined(CONFIG_VIDEO_MT9T111_MODULE)
241 + {
242 + I2C_BOARD_INFO("mt9t111", MT9T111_I2C_ADDR),
243 + .platform_data = &mt9t111_pdata,
244 + },
245 +#endif
246 };
248 static int __init omap3_beagle_i2c_init(void)
249 --
250 1.6.6.1