aboutsummaryrefslogtreecommitdiffstats
path: root/extras/recipes-kernel/linux/linux-omap-psp-2.6.32/cam/0004-omap3beagle-Add-camera-support.patch
blob: 511bd93c377e14eb71fe3ecaa08e4c52b08a4a28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
From 8b7b00860ac8c558c7156ff676655942027f7f53 Mon Sep 17 00:00:00 2001
From: Sergio Aguirre <saaguirre@ti.com>
Date: Fri, 11 Jun 2010 16:15:58 -0500
Subject: [PATCH 04/75] omap3beagle: Add camera support

This is tested with the xM + Leopard imaging module camera, which
has a MT9T111.

Signed-off-by: Sergio Aguirre <saaguirre@ti.com>
---
 arch/arm/mach-omap2/Makefile                   |    3 +-
 arch/arm/mach-omap2/board-omap3beagle-camera.c |  228 ++++++++++++++++++++++++
 arch/arm/mach-omap2/board-omap3beagle-camera.h |   41 +++++
 arch/arm/mach-omap2/board-omap3beagle.c        |   25 +++
 4 files changed, 296 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/board-omap3beagle-camera.c
 create mode 100644 arch/arm/mach-omap2/board-omap3beagle-camera.h

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 9042317..a49d436 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -87,7 +87,8 @@ obj-$(CONFIG_MACH_OMAP_2430SDP)		+= board-2430sdp.o \
 					   mmc-twl4030.o
 obj-$(CONFIG_MACH_OMAP_APOLLON)		+= board-apollon.o
 obj-$(CONFIG_MACH_OMAP3_BEAGLE)		+= board-omap3beagle.o \
-					   mmc-twl4030.o
+					   mmc-twl4030.o \
+					   board-omap3beagle-camera.o
 obj-$(CONFIG_MACH_OMAP_LDP)		+= board-ldp.o \
 					   mmc-twl4030.o \
 					   board-ldp-camera.o
diff --git a/arch/arm/mach-omap2/board-omap3beagle-camera.c b/arch/arm/mach-omap2/board-omap3beagle-camera.c
new file mode 100644
index 0000000..e93437f
--- /dev/null
+++ b/arch/arm/mach-omap2/board-omap3beagle-camera.c
@@ -0,0 +1,228 @@
+/*
+ * Driver for Leopard Module Board used in Beagleboard (xM)
+ *
+ * Copyright (C) 2010 Texas Instruments Inc
+ * Author: Sergio Aguirre <saaguirre@ti.com>
+ *
+ * Based on work done by:
+ *     Vaibhav Hiremath <hvaibhav@ti.com>
+ *     Anuj Aggarwal <anuj.aggarwal@ti.com>
+ *     Sivaraj R <sivaraj@ti.com>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+#include <linux/mm.h>
+#include <linux/videodev2.h>
+#include <linux/i2c/twl.h>
+#include <linux/delay.h>
+
+#include <plat/mux.h>
+#include <plat/board.h>
+
+#include <media/v4l2-int-device.h>
+#include <media/mt9t111.h>
+
+/* Include V4L2 ISP-Camera driver related header file */
+#include <../drivers/media/video/omap34xxcam.h>
+#include <../drivers/media/video/isp/ispreg.h>
+
+#include "mux.h"
+#include "board-omap3beagle-camera.h"
+
+#define MODULE_NAME			"omap3beaglelmb"
+
+#define MT9T111_I2C_BUSNUM	(2)
+
+#define CAM_USE_XCLKA       1
+
+#if defined(CONFIG_VIDEO_MT9T111) || defined(CONFIG_VIDEO_MT9T111_MODULE)
+static struct isp_interface_config mt9t111_if_config = {
+	.ccdc_par_ser		= ISP_PARLL, 
+	.dataline_shift		= 0x0,
+	.hsvs_syncdetect	= ISPCTRL_SYNC_DETECT_VSRISE,
+	.strobe			= 0x0,
+	.prestrobe		= 0x0,
+	.shutter		= 0x0,
+	.u.par.par_bridge	= 0x1,
+	.u.par.par_clk_pol	= 0x0,
+};
+
+static struct v4l2_ifparm mt9t111_ifparm_s = {
+#if 1
+	.if_type = V4L2_IF_TYPE_RAW, 
+	.u 	 = {
+		.raw = {  
+			.frame_start_on_rising_vs = 1,
+			.bt_sync_correct	= 0,
+			.swap			= 0,
+			.latch_clk_inv		= 0,
+			.nobt_hs_inv		= 0,	/* active high */
+			.nobt_vs_inv		= 0,	/* active high */
+			.clock_min		= MT9T111_CLK_MIN,
+			.clock_max		= MT9T111_CLK_MAX,
+		},
+	},
+#else		
+	.if_type = V4L2_IF_TYPE_YCbCr, 
+	.u 	 = {
+		.ycbcr = {  
+			.frame_start_on_rising_vs = 1,
+			.bt_sync_correct	= 0,
+			.swap			= 0,
+			.latch_clk_inv		= 0,
+			.nobt_hs_inv		= 0,	/* active high */
+			.nobt_vs_inv		= 0,	/* active high */
+			.clock_min		= MT9T111_CLK_MIN,
+			.clock_max		= MT9T111_CLK_MAX,
+		},
+	},
+#endif
+};
+
+/**
+ * @brief mt9t111_ifparm - Returns the mt9t111 interface parameters
+ *
+ * @param p - pointer to v4l2_ifparm structure
+ *
+ * @return result of operation - 0 is success
+ */
+static int mt9t111_ifparm(struct v4l2_ifparm *p)
+{
+	if (p == NULL)
+		return -EINVAL;
+
+	*p = mt9t111_ifparm_s;
+	return 0;
+}
+
+#if defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
+static struct omap34xxcam_hw_config mt9t111_hwc = {
+	.dev_index		= 0,
+	.dev_minor		= 0,
+	.dev_type		= OMAP34XXCAM_SLAVE_SENSOR,
+	.u.sensor.sensor_isp	= 1,
+};
+#endif
+
+/**
+ * @brief mt9t111_set_prv_data - Returns mt9t111 omap34xx driver private data
+ *
+ * @param priv - pointer to omap34xxcam_hw_config structure
+ *
+ * @return result of operation - 0 is success
+ */
+static int mt9t111_set_prv_data(void *priv)
+{
+#if defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
+	struct omap34xxcam_hw_config *hwc = priv;
+
+	if (priv == NULL)
+		return -EINVAL;
+
+	hwc->u.sensor = mt9t111_hwc.u.sensor;
+	hwc->dev_index = mt9t111_hwc.dev_index;
+	hwc->dev_minor = mt9t111_hwc.dev_minor;
+	hwc->dev_type = mt9t111_hwc.dev_type;
+	return 0;
+#else
+	return -EINVAL;
+#endif
+}
+
+/**
+ * @brief mt9t111_power_set - Power-on or power-off TVP5146 device
+ *
+ * @param power - enum, Power on/off, resume/standby
+ *
+ * @return result of operation - 0 is success
+ */
+static int mt9t111_power_set(struct v4l2_int_device *s, enum v4l2_power power)
+{
+	struct omap34xxcam_videodev *vdev = s->u.slave->master->priv;
+
+	switch (power) {
+	case V4L2_POWER_OFF:
+		isp_set_xclk(vdev->cam->isp, 0, CAM_USE_XCLKA);
+		break;
+
+	case V4L2_POWER_STANDBY:
+		break;
+
+	case V4L2_POWER_ON:
+		isp_set_xclk(vdev->cam->isp, MT9T111_CLK_MIN, CAM_USE_XCLKA);
+
+#if defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
+		isp_configure_interface(vdev->cam->isp, &mt9t111_if_config);
+#endif
+		break;
+
+	default:
+		return -ENODEV;
+		break;
+	}
+	return 0;
+}
+
+static struct mt9t111_platform_data mt9t111_pdata = {
+	.master		= "omap34xxcam",
+	.power_set	= mt9t111_power_set,
+	.priv_data_set	= mt9t111_set_prv_data,
+	.ifparm		= mt9t111_ifparm,
+	/* Some interface dependent params */
+	.clk_polarity	= 0, /* data clocked out on falling edge */
+	.hs_polarity	= 1, /* 0 - Active low, 1- Active high */
+	.vs_polarity	= 1, /* 0 - Active low, 1- Active high */
+};
+
+static struct i2c_board_info __initdata mt9t111_i2c_board_info = {
+	I2C_BOARD_INFO("mt9t111", MT9T111_I2C_ADDR),
+	.platform_data	= &mt9t111_pdata,
+};
+
+#endif				/* #ifdef CONFIG_VIDEO_MT9T111 */
+
+/**
+ * @brief omap3beaglelmb_init - module init function. Should be called before any
+ *                          client driver init call
+ *
+ * @return result of operation - 0 is success
+ */
+int __init omap3beaglelmb_init(void)
+{
+	int err;
+
+	/*
+	 * Register the I2C devices present in the board to the I2C
+	 * framework.
+	 * If more I2C devices are added, then each device information should
+	 * be registered with I2C using i2c_register_board_info().
+	 */
+#if defined(CONFIG_VIDEO_MT9T111) || defined(CONFIG_VIDEO_MT9T111_MODULE)
+	err = i2c_register_board_info(MT9T111_I2C_BUSNUM,
+					&mt9t111_i2c_board_info, 1);
+	if (err) {
+		printk(KERN_ERR MODULE_NAME \
+				": MT9T111 I2C Board Registration failed \n");
+		return err;
+	}
+#endif
+	printk(KERN_INFO MODULE_NAME ": Driver registration complete \n");
+
+	return 0;
+}
+arch_initcall(omap3beaglelmb_init);
diff --git a/arch/arm/mach-omap2/board-omap3beagle-camera.h b/arch/arm/mach-omap2/board-omap3beagle-camera.h
new file mode 100644
index 0000000..1026aeb
--- /dev/null
+++ b/arch/arm/mach-omap2/board-omap3beagle-camera.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 Texas Instruments Inc
+ * Author: Sergio Aguirre <saaguirre@ti.com>
+ *
+ * Based on work done by:
+ *    Vaibhav Hiremath <hvaibhav@ti.com>
+ *    Anuj Aggarwal <anuj.aggarwal@ti.com>
+ *    Sivaraj R <sivaraj@ti.com>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __BOARD_OMAP3BEAGLE_LMB_H_
+#define __BOARD_OMAP3BEAGLE_LMB_H_
+
+/* mux id to enable/disable signal routing to different peripherals */
+enum omap3beaglelmb_mux {
+	MUX_TVP5146 = 0,
+	MUX_CAMERA_SENSOR,
+	MUX_EXP_CAMERA_SENSOR,
+	NUM_MUX
+};
+
+/* enum to enable or disable mux */
+enum config_mux {
+	DISABLE_MUX,
+	ENABLE_MUX
+};
+
+#endif		/* __BOARD_OMAP3BEAGLE_LMB_H_ */
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index b313350..d6b69a6 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -712,6 +712,31 @@ static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = {
 
 #ifdef CONFIG_OMAP_MUX
 static struct omap_board_mux board_mux[] __initdata = {
+	/* Camera - Parallel Data */
+	OMAP3_MUX(CAM_D0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_D1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_D2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_D3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_D4, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_D5, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_D6, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_D7, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_D8, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_D9, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_D10, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_D11, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_PCLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+
+	/* Camera - HS/VS signals */
+	OMAP3_MUX(CAM_HS, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+	OMAP3_MUX(CAM_VS, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
+
+	/* Camera - Reset GPIO 98 */
+	OMAP3_MUX(CAM_FLD, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
+
+	/* Camera - XCLK */
+	OMAP3_MUX(CAM_XCLKA, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT),
+
 	{ .reg_offset = OMAP_MUX_TERMINATOR },
 };
 #else
-- 
1.6.6.1